bookmark_borderUsing PowerShell core in Visual Studio Code on windows

This is more for me than anyone else. If you want to move to PowerShell core in Visual Studio Code then do the following.

  1. Press CTRL + , to open settings.
  2. Enter terminal in the search box.
  3. Scroll down to Terminal > Integrated > Shell: Windows
  4. Click on ‘Edit in settings.json’ and add the following.
    "terminal.integrated.automationShell.windows": "c:/tools/pwsh/pwsh.exe",
    "terminal.integrated.shell.windows": "c:/tools/pwsh/pwsh.exe"

Now when the terminal is opened it will be using PowerShell 6 / Core.

To install the PowerShell Core / 6 got to https://github.com/powershell/powershell

Sytone

I’m a principal engineer working at Microsoft. I have run and supported services for over twenty years and worked in multiple countries. I love working with passionate people and new technology.

bookmark_borderRooting the WINK Hub with Windows

I do have a Linux machine in the house but that is on a Pi running as a squeezelite client for my house music collection. So looking at the instructions on the web I have translated them for use in Windows. Of course I have use PowerShell! The only addition I have is I use Kitty as a SSH client. This uses the approach @ http://www.dinnovative.com/?p=348

  1. Open up the box and plug in the WINK unit. Do not download any app or hook it up to the internet. If you do this the latest firmware will overwrite the ability to do the hack below without popping open the case and hitting the chip directly.
  2. When you have the pink flashing light open a laptop and connect to the WINK wireless network. It starts with WINKHUB….
  3. Open a browser and go to http://192.168.0.1 and you should see home page or a download prompt for a JSON file. If so all good!
  4. Open up a PowerShell instance.
  5. Run:
    Invoke-WebRequest -Uri http://192.168.0.1/set_dev_value.php -Method Post -Body @{nodeId='a';attrId=";dropbearkey -t rsa -f /root/.ssh/winkkey.dbprv.rsa > /root/.ssh/winkkey.rawpub.rsa;"}
    Invoke-WebRequest -Uri http://192.168.0.1/set_dev_value.php -Method Post -Body @{nodeId='a';attrId=";dropbearconvert dropbear openssh /root/.ssh/winkkey.dbprv.rsa /var/www/winkkey.rsa;"}
    Invoke-WebRequest -Uri http://192.168.0.1/set_dev_value.php -Method Post -Body @{nodeId='a';attrId=";grep ssh /root/.ssh/winkkey.rawpub.rsa > /root/.ssh/authorized_keys;"}
    Invoke-WebRequest -Uri http://192.168.0.1/winkkey.rsa -OutFile winkkey.rsa
  6. You now should have the rsa key locally. If you are using kitty/putty you need to get putty gen and open the rsa file up and then save it as a putty version of the key. You can then open up putty/kitty and access the WINK hub.

Reference Links:

  • http://www.rootwink.com/index.php
  • http://arahuman.blogspot.com/2014/11/how-to-root-your-wink-hub-step-by-step.html
  • http://www.dinnovative.com/?p=348
  • https://winkhubroot.wordpress.com/
  • http://forum.xda-developers.com/general/off-topic/wink-hub-root-t2969205
Sytone

I’m a principal engineer working at Microsoft. I have run and supported services for over twenty years and worked in multiple countries. I love working with passionate people and new technology.

bookmark_borderIntegrating ISY into OpenHAB

I am in the process of setting up OpenHAB for the extra functionality in my house. I have the ISY unit setup as the core brains for switches and scenes. All the other magic is in OpenHAB so if OpenHAB goes down the main functions of the house work.

I wanted to get the OpenHAB system to be able to get the status from the ISY unit and also changes states. This was as not straight forward as I wanted. I still have a issue that the process is polling and not a subscriber model but I do not have time to create a ISY binding.

Anyway, here’s the basic instructions.

1. Generate a basic auth hash for your user/pass to access the ISY admin console. In PowerShell use the following command:
[code]
$user = "usernameforisy"
$pass = "passwordforusername"
[Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($("{0}:{1}" -f $user, $pass)))
[/code]

2. Edit the OpenHAB items file and add in your switch, replace 1.2.3.4 with the IP of your ISY unit and change the word HASH to the auth hash generated in step one. You use the ID of the switch not the friendly name, replace any spaces with %%20 so 11 22 33 1 becomes 11%%2022%%2033%%201

[code]
Switch NAMEOFSWITCH "Floor Lamp [%s]" (g_FF,Lights,g_FF_Study) {http="&lt;[http://<strong>1.2.3.4</strong>/rest/nodes/<strong>11%%2022%%2033%%201</strong>/{Authorization=Basic <strong>HASH</strong>}:10000:XSLT(isy_node_state.xsl)] &gt;[ON:GET:http://<strong>1.2.3.4</strong>/rest/nodes/<strong>11%%2022%%2033%%201</strong>/cmd/DFON/{Authorization=Basic <strong>HASH</strong>}] &gt;[OFF:GET:http://<strong>1.2.3.4</strong>/rest/nodes/<strong>11%%2022%%2033%%201</strong>/cmd/DFOF{Authorization=Basic <strong>HASH</strong>}]"}
[/code]

3. Save the following XSL code to the transform folder under configuration and name it isy_node_state.xsl

[code]
&lt;?xml version="1.0"?&gt;
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0"&gt;
&lt;xsl:output indent="yes" method="xml" encoding="UTF-8" omit-xml-declaration="yes" /&gt;
&lt;xsl:template match="/"&gt;
&lt;xsl:value-of select="translate(//nodeInfo/node/property/@formatted,’abcdefghijklmnopqrstuvwxyz’,’ABCDEFGHIJKLMNOPQRSTUVWXYZ’)" /&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
[/code]

Sytone

I’m a principal engineer working at Microsoft. I have run and supported services for over twenty years and worked in multiple countries. I love working with passionate people and new technology.