• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
TRIGGERcmd
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

HomeGenie X10 control with single bash script

Raspberry Pi
raspberry pi google assistan alexa homegenie x10
4
15
1.6k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    tuicemen @tuicemen
    last edited by tuicemen Jan 9, 2022, 12:07 AM Jan 9, 2022, 12:06 AM

    @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

    T 1 Reply Last reply Jan 9, 2022, 6:07 PM Reply Quote 1
    • T
      tuicemen @tuicemen
      last edited by Jan 9, 2022, 6:07 PM

      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.

      W 1 Reply Last reply Jan 12, 2022, 2:12 PM Reply Quote 0
      • W
        Wholepunch @tuicemen
        last edited by Jan 12, 2022, 2:12 PM

        @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.

        T 1 Reply Last reply Jan 12, 2022, 3:44 PM Reply Quote 0
        • T
          tuicemen @Wholepunch
          last edited by Jan 12, 2022, 3:44 PM

          @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.

          W T 2 Replies Last reply Jan 12, 2022, 4:14 PM Reply Quote 0
          • W
            Wholepunch @tuicemen
            last edited by Jan 12, 2022, 4:14 PM

            @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!

            1 Reply Last reply Reply Quote 0
            • T
              tuicemen @tuicemen
              last edited by Jan 12, 2022, 7:01 PM

              @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.

              T 1 Reply Last reply Jan 26, 2022, 5:04 PM Reply Quote 0
              • T tuicemen referenced this topic on Jan 25, 2022, 4:26 PM
              • T
                tuicemen @tuicemen
                last edited by Jan 26, 2022, 5:04 PM

                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

                1 Reply Last reply Reply Quote 0
                • T
                  tuicemen
                  last edited by tuicemen Feb 6, 2022, 8:50 PM Feb 6, 2022, 4:51 PM

                  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

                  R 1 Reply Last reply Feb 6, 2022, 5:58 PM Reply Quote 0
                  • R
                    Russ @tuicemen
                    last edited by Russ Feb 6, 2022, 5:58 PM Feb 6, 2022, 5:58 PM

                    @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.

                    Russell VanderMey

                    T 1 Reply Last reply Feb 6, 2022, 8:49 PM Reply Quote 0
                    • T
                      tuicemen @Russ
                      last edited by tuicemen Feb 6, 2022, 9:16 PM Feb 6, 2022, 8:49 PM

                      @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.

                      1 Reply Last reply Reply Quote 1
                      • First post
                        Last post