bookmark_borderUsing Microsoft Flow with Home Assistant

Now that Microsoft Flow is out of Beta I thought I would play with it and integrate it with Home Assistant running my house. The Microsoft Flow is fairly flexible and has more flow options than IFTTT to make choices.

To use this with Home Assistant I am going to use the REST API to make and set a sensor value, you can then take this and make it as complicated as you want. 🙂

Settings

You need to ensure you have this information at hand.
* Home Assistant Endpoint – https://publicdomin:optionalPort/api
* Your password for the http component. If you public expose HA without a password, stop and fix it now!
* The name of the sensor you want to update. sensor.kitchen_temperature in this case.

  1. Go to https://flow.microsoft.com and login.
  2. Make a new Flow from a blank template
  3. Search for button (you can use other triggers but this is an easy start)
  4. Add a new step of type action.
  5. Select HTTP
  6. Change Method to POST
  7. In URI put the full URI of the sensor you want to change. Using the data above this is https://publicdomin:optionalPort/api/states/sensor.kitchen_temperature
  8. In headers add the following JSON blob.
    {
    “x-ha-access”: “YOURPASSWORD”,
    “Content-Type”: “application/json”
    }
  9. In Body put the JSON to update the sensor.
    {
    “state”: “25”,
    “attributes”: {
    “unit_of_measurement”: “°C”
    }
    }
  10. Save the Flow!

Now open up Flow on your phone and log in with the same account, you will see a nice big button with manual -> HTTP on it. Click that button and look at the state of the sensor in Home Assistant. You will see it with the value you set in the body.

To trouble shoot, in the web UI click on the i with a circle around it. It will show a log of successes and failures. If you click on that you can drill into the details of the flow and the responses from Home Assistant.

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.