Tuesday 20 June 2017

HOME AUTOMATION: Google Home Assistant + Say a simple phrase with a number + openHAB

I've spent a bit of time integrating IR blasters in to my openHAB setup to gain control of my TV and AC. I was able to get simple functions working with the basic "Say a simple phrase" but this wasn't cutting it for something like controlling the volume of the TV so I've written a script that executes a command a given number of times based on the "Say a simple phrase with a number" action in IFTTT. This way I can say "Turn up the TV volume by 10".

 #!/bin/sh  
 # execute the command multiple times based on command line argument  
 for i in $(seq 1 $1); do  
  python /home/openhabian/addons/BlackBeanControl/BlackBeanControl.py -c LG_TV_V$  
 done  

I put my scripts in the /etc/openhab2/scripts folder.
You will need to create a thing/item combination that uses the Exec binding as I've done here.
To test the command is working as expected use the command:

 bash /etc/openhab2/scripts/tv_lounge_volume_down.sh 5  

If everything went well you should see your command executed 5 times. Pair this with my instructions on connecting openHAB with the Google Home Assistant and you should be set.

For reference this is what my applet looks like at the command end.


No comments:

Post a Comment