HomeGenie X10 control with single bash script
-
@russ the cool thing is, like TRIGGERcmd it can be used on a variety of OSs, Mac, Windows, Linux, Raspi
-
@tuicemen I was wondering if people were still using X10 besides me. I ended up using an old broadlink RM Pro to control mine. I just use the newest Broadlink app, (Not IHC, and no IFTTT) and it controls all my x10 devices and also has ir, so it can also control my dumb TV, surround, fireplace, etc. There is no subscription fees with this either.
-
@alwaysbroke, there are a number of users still on the X10 band wagon as can be seen on the X10 forums ( https://forums.x10.com ).
I have used the Broadlink RM, Samsung SmartThings developer console, and Ha-Bridge and a few other methods to get Alexa control in the past.
The easiest by far to setup was HA-Bridge however currently there is a issue with adding new devices which started to affect me as well as several others. This lead me to TRIGGERcmd.
I'm not a big fan of subscription fees either but if reasonable and it does what I require it is worth it.
HomeGenie is free and I created several addon plugins for it so interfacing to it is best for me. HA-Bridge did this seamless when it was working. I'm sure Triggercmd will do this as well once I have all the bugs worked out. The limitation of one call per min for the non subscription is slowing testing things up here for sure. One call every 30 seconds would sure speed up my testing but once everything is setup 1 call per min I think I can live with for most things Alexa and every thing Google Home is used for here. -
@Russ , seems Alexa and Google send lower case on/off commands and HomeGenie requires the commands to start with upper case. I'm not sure why with using just 1 parameter this seems to work but with 3 parameters it doesn't
In any case I've got a work around for this in the Bash script which I edited to look like this now
#!/bin/bash foo=$(echo "${3}" | awk '{$1=toupper(substr($1,0,1))substr($1,2)}1') echo Sent HomeGenie the $1 command $2 to turn $foo >> /home/pi/scripts/HGsents.txt echo "Sending HomeGenie the $1 command $2 to turn $foo" curl http://192.168.0.24:8084/api/HomeAutomation.$1/$2/Control.$foo
next I'll start to play with adding dim commands but not sure if TRIGGERcmd will process them from Alexa/Google
-
I rarely if ever use dim commands and when I do it is for a single lamp and to set it to a specific level.
Since TRIGGERcmd currently doesn't accept dim commands from Alexa or Google the dim operation is a set value (that works for me) if you wish a different value the script would require editing.
If in the future @Russ adds dimming I'll rework this bash script.
I'll edit my OP showing the revised script. -
@tuicemen Thanks for this - looks like an elegant solution. I've been putting together a Home Assistant (Hassio) build having tried OpenHab and several others but hadn't come across Home Genie for some reason so you've prompted me to do some research - I find Hassio a bit restrictive / cumbersome for some of the things I want to implement, although the work put into making it a polished user experience is very evident.
-
@wholepunch, one thing I like about HomeGenie is it has it's own drivers for X10 unlike the other Multi OS HA software solutions.
The Developer isn't as quick at resolving issues and the user base isn't as big as it use to be(perhaps due to that fact).
The user base that have stuck with it are very knowledgeable so most issues that are discovered are usually fixed with a workaround. Having different built in coding languages means most anyone can develop plugins for it. -
@tuicemen That's useful to know - thank you! I must admit that I thought that pure X10 devices had been steam-rollered by ZWave, ZigBee at al - but that just shows you what a home automation noob I am. I fully agree with your comments re: some other HA systems - Hassio in particular seems to want to move to a binary " that's supported/not supported" model, which I understand for the purposes of user friendliness and stability, but it's frustrating for the tinkerer!
-
@wholepunch, since @Russ posted https://www.triggercmd.com/forum/post/5208 I got thinking about HG responding back to the API request. It may be possible to add a custom response to device calls indicating that HG did actually receive and perform the task.
Creating a variable Received for the Curl call
then using a"if [ $Recieved='{"ResponceValue":OK}' ] then ........
one could have TRIGGERcmd report that HG did indeed send the command or not via Alexa or Google.
I don't wish to play with Voice Monkey unless I have to.
-
-
I reworked the hg script to handle how I suspect alexa or Google will send the dim command to TRIGGERcmd when(if) @Russ is able to add that feature it presumes the HG server is running on the same PI as TRIGGER and is on port 8080
#!/bin/bash foo=$(echo "${3}" | awk '{$1=toupper(substr($1,0,1))substr($1,2)}1') if [ -n "$foo" ] && [ "$foo" -eq "$foo" ] 2>/dev/null; then( #following turns device to the brigtness level curl -s http://localhost:8080/api/HomeAutomation.$1/$2/Control.Level/$foo echo "Sent HomeGenie the $1 command $2 to $foo % brightness" ) else( curl -s http://localhost:8080/api/HomeAutomation.$1/$2/Control.$foo echo "Sent HomeGenie the $1 command $2 to turn $foo" ) fi #if next line uncomented it will log commands sent to a already created file HGsents.txt #echo Sent HomeGenie the $1 command $3 to $2 >> /home/pi/scripts/HGsents.txt
You can test the script from the command line for on/off and dim
Using sh hg.sh X10 A3 50 this would set the X10 module A3 to 50%
for those that don't wish to create this file you can download it here: script -
I'm happy to report the above posted script works for Dimming via Alexa since @Russ added support in the Alexa skill.
You do need to have Alexa rediscover those dimmable lights -
@tuicemen said in HomeGenie X10 control with single bash script:
"deviceType":"light"
This is actually wrong ^. "deviceType":"light" is not a thing.
If adding that made it work, it's because when you change a command, TRIGGERcmd deletes and re-creates the Alexa smart home device. That needed to happen for the Alexa device associated with your command would have the new brightness feature.
Sorry I didn't tell you that in my reply to your post where I told you it should work now.
-
@russ thanks, I removed the deviceType from my json file and had Alexa rediscover and they do still dim. I edited my previous post.
It should be noted that using dim turns the device to that value. So if you turn a light on (100%) then say dim 20% it doesn't set the light level to 80 but instead sets the light level to 20.
At least that's the way it works for HG.