Saturday, April 15, 2017

Motion Lights using Philips Hue with Z-Wave Sensors


To work around the limitations of Fibaro HCL that does not allow you to use LUA scripts, Domotics fill that gap and allows you to use more than just Z-wave devices.

The major problem with using Hue with the HCL, is that the Hue API requires action via a HTTP PUT to change the state of the lights. The HCL only allows HTTP GET using the string method for Virtual Devices.

Domoticz allows you to add Hue directly as "Hardware" and automatically adds all the  bulbs and scenes as "Devices". To trigger the API to Domoticz, we use HTTP GET (yes, that is a Yay!!!).

Create a 2 button virtual device with the following string using the IP address and port of the Domoticz server

On button:

GET /json.htm?type=command&param=switchlight&idx=&switchcmd=On&level=0&passcode= HTTP/1.10x0D0x0A0x0D0x0A

Off  button:

GET /json.htm?type=command&param=switchlight&idx=&switchcmd=Off&level=0&passcode= HTTP/1.10x0D0x0A0x0D0x0A

When we create the new scene with the motion sensor being "breached", we can then select the On to link to the new Virtual Device.

Now for the vanity part where we can use Domotics FibaroLink to update the status of the virtual device label in Fibaro. This is best described in this link : http://www.vesternet.com/resources/application-notes/apnt-87#.WPHGlIh96Cg


.





Monday, April 03, 2017

Alexa, Turn on Computer

There is many ways to wake your computer up and put your computer to hibernate using Alexa.

I will use:

1. computer with cygwin enabled with sshd service
2. domoticz on a raspberry pi
3. ha-bridge on raspberry pi
4. Amazon echo

I'm more of a computer user than a developer, but I find that Domoticz is great as it helps non-developers download unix commands and allow a direct call to shell scripts.

More great things about Domoticz is that it convert HTTP POST to GET methods when you are using triggers that can't do POST to Philips Hue lights (I will cover that in another post)


Step 1: Setup a dummy hardware used for virtual switches



Step 2: Create a virtual sensor as a light switch called Computer

For the On script use:
script:///home/pi/domoticz/scripts/pc-wake.sh

The bash script should contain

#!/bin/bash
wakeonlan  BC:5F:F4:88:92:B6


For the Off script use:
script:///home/pi/domoticz/scripts/pc-hibernate.sh

This bash script contents are; (Replace X with the IP address of the computer)

#!/bin/bash
ssh user@192.168.1.X "shutdown /h" &


The off switch assumes you have an sshd service running on your computer with private keys installed on the raspberry pi with no password so it auto autenticates and runs without entering a password. Windows 10 command to hibernate is shutdown /h

You will need to google again to find out how to setup sshd, as it's too long to put into this post.


For ha-bridge to use this, add the domoticz command to Computer (Replace NN with switch ID, you can get this from the devices tab under the "Setup" drop down.

On
http://192.168.1.Y:8080/json.htm?type=command&param=switchlight&idx=NN&switchcmd=On

Off
http://192.168.1.Y:8080/json.htm?type=command&param=switchlight&idx=NN&switchcmd=Off


To use

Alexa, turn on computer
Alexa, turn off computer






Sunday, April 02, 2017

Alexa Turn On / Off TV


I have a Samsung LED smart TV. The "smart" TV let's you turn off the TV, but it doesn't let you turn it on as the IP address is not available when it's off.

That sort of makes sense.

While it is possible to then download a command to turn off the TV. you will need to go through the TV settings to enable HDMI-CEC. This means that turning on the apple TV for example will in turn turn on the TV and set the channel to Apple TV.


What you need.

1. Domoticz
2. iSamsung command (https://www.domoticz.com/wiki/Samsung_TV)
3. atvremote command (i took this from homeassistant)


Use Domoticz to create a dummy device and add a virtual selector device.




There are 4 buttons I programmed and here are the corresponding commands.

if your TV has the IP address 192.168.1.x (Replace x with the actual IP address of the TV)

To turn the TV off
script:///usr/local/bin/iSamsungTV 192.168.1.x -KEY KEY_POWEROFF

To use Apple TV to turn on the TV to Apple TV channel
script:///srv/homeassistant/bin/atvremote -a menu

To change the channel another HDMI input
script:///usr/local/bin/iSamsungTV 192.168.1.x -KEY KEY_HDMI

To change the channel to COMPONENT input
script:///usr/local/bin/iSamsungTV 192.168.1.x -KEY KEY_COMPONENT1


Now that we have Domoticz working, we need to add the buttons to ha-bridge for Alexa commands

For Domotics IP 192.168.1.y (Replace y) and switch ID is NN (Replace NN with the actual switch ID

To turn on the TV
http://192.168.1.y:8080/json.htm?type=command&param=switchlight&idx=NN&switchcmd=Set%20Level&level=10


to turn off the TV
http://192.168.1.y:8080/json.htm?type=command&param=switchlight&idx=NN&switchcmd=Set%20Level&level=0


To change the channel, we can create another ha-bridge device and just leave the turn on button for HDMI and Cable TV, respectively

http://192.168.1.y:8080/json.htm?type=command&param=switchlight&idx=NN&switchcmd=Set%20Level&level=20
http://192.168.1.y:8080/json.htm?type=command&param=switchlight&idx=NN&switchcmd=Set%20Level&level=30



To Use these command with Alexa, you can say this.

Alexa, Turn On TV (Defaults to Apple TV)
Alexa, Turn Off TV
Alexa, Turn On HDMI (does a round robin approach to HDMI surfing
Alexa, Turn On Cable TV (changes the channel to component which is my cable box)




Splitting the home network

Who wouldn't want to separate the traffic at home for security reasons. The more common ones include wireless guest and wireless users. ...