No announcement yet.

Node-Red, HS4, and Alexa

  • Filter
  • Time
  • Show
Clear All
new posts

    Node-Red, HS4, and Alexa

    Has anyone been working with Node-Red, Homeseer, and Alexa? I have been able to get Homeseer to talk to Alexa, to make announcements everywhere, or to speak to a specific echo, but since I've been putting my script in Homeseer, I cannot find a way to send my response back to the echo that asked the question. I'm thinking I'll need to put my code into node-red, instead of in Homeseer. I have HS4 integration with Homeseer, and am using node-red-contrib-alexa-remote2 to talk to Alexa.

    Does anyone have any pointers, or better yet, sample flows that I can try out?

    Much Appreciated,

    I don't think the Alexa node that can do the announcements and speak can actually make her listen for a reply and then send it back to the flow. I don't think listening for a reply from the user is part of what Amazon considers an "announcement". Jon00's Alexa helper can do this but it can't push an unprompted announcement. You will have to trigger it with a voice command but it can do prompt and reply.


      Let me preface this by saying I don't code well, and probably have no idea what I'm talking about. But, if in Node-red, I drag in an Alexa Event, and set it to my account under "account" and "device activity" under command, and send that to debug with the complete message object, I can see everything asked to Alexa, and it shows me the entire message info, including the device serial number and name that asked the question. So it looks like it may be possible to get the info of which Alexa device asked, but would require minds greater than mine to figure out how to take all the pieces and make it work.


        The Alexa Event node does behave as you say. I use it to capture non-room-specific commands like "turn on the fan" and then append the name of the Alexa device that heard the command (ex: Living Room) and then send it on to HomeSeer looking like "turn on the Living Room fan".

        Unfortunately, I still don't know of a way to send an announcement to an Alexa and then immediately put the device into the mode where it listens for a reply. If this could be done, then you could probably use the Event node to catch the reply and act accordingly.


          So right now, I have a routine setup in Alexa:
          "Alexa, tell me the garage door status"
          The routine runs a HS event, called Gstatus, where I run a script to check the garage status, and send back 1 of 4 commands:

          If the doors are closed, it sends:
          call hs.URLAction("http://ipofnodered:1880/HS3?Action=Speak&Where=John's Office&Volume=100&SayWhat=Both Garage Doors are closed", "GET", "", "")

          Left open:
          call hs.URLAction("http://ipofnodered:1880/HS3?Action=Speak&Where=John's Office&Volume=100&SayWhat=Garage Door Left is open", "GET", "", "")

          Right open:
          call hs.URLAction("http://ipofnodered:1880/HS3?Action=Speak&Where=John's Office&Volume=100&SayWhat=Garage Door Right is open", "GET", "", "")

          Both open:
          call hs.URLAction("http://ipofnodered:1880/HS3?Action=Speak&Where=John's Office&Volume=100&SayWhat=Both Garage Doors are open", "GET", "", "")

          (As you can see in my calls above, I am Specifying "&Where=John's Office"
          If I leave that piece out, it would say to all Echos throughout the house)

          From my office Alexa, when I say:
          "Alexa, tell me the garage door status"
          Alexa replies "OK"
          (short pause)
          "Both Garage doors are closed"

          And I'm fine with the "OK" spoken before the status comes back. Yes it would be nice, as you say, to put it into a mode where it listens for a reply, so as not to get the "OK", but I'll take what I can get

          What I'm not fine with (read: What MY WIFE is not fine with) is that if I were in the basement, and wanted to check the garage status, I can either set them to speak to my office (which I cannot hear from the basement) or to everywhere (which I can hear on the basement Echo, but so can my wife on her office echo, hence the issue)

          So (if you're still reading): How are you able to append the name of the device, and send it to Homeseer? Because if I could get the name of the device that sent the command, and send it to Homeseer, couldn't I then send it back in the "&Where=" part of my calls above? Then aside from the "OK", which I can live with, all would be right with the world.

          -Except for the Covid thing.


            I think we can do that. Here is how I would tackle it:

            1) Disable your HS event but leave the Alexa routine so that you can use your "tell me the garage door status" phrase without Alexa acting confused.
            2) Use the Echo Event node to "listen" in Node-Red for this specific phrase. The node fires every time an Echo hears the wake word.
            3) Build a flow that does the following:
            4) Strips the wake word from msg.payload.description.summary
            5) Proceeds if msg.payload.description.summary = "tell me the garage door status"
            6) Use the http request node to send HTTP GET to http://yourhomeseer/JSON?request=getstatus&ref=<REF>
            7) Connect output of http request to JSON parser node. The status of the device should be at msg.payload.Devices[0].status
            8) Build an Alexa announcement using the name of the triggered device from and the device status that the http request node returned.
            9) Send Alexa announcement

            This builds all the logic into Node-Red instead of HomeSeer's event system. I have moved a lot of overly complicated events into NR Flows because of it's ease and flexibility. You may find that the http request node will replace the entire msg object in the flow. If so you may lose the name of the triggering Alexa ( It may be necessary to save this value in a flow variable for safekeeping until the end of the flow. This flow could certainly be expanded to work with a variety of different verbal triggers. You could use a switch node to match different spoken phrases and then based on the phrase, set a variable with the HS device REF which is then sent to a single http request node.

            This is just a high level overview and may not work without tweaking.


              Thanks @AZweimiller, that's exactly the info I needed. So, now I just have to get to work on it. I'll send you an update when I am able to get something functional together, and will share my flow. Mind you, I don't really code, so if you don't see a response from me for a while, I haven't died. I'm just struggling to learn how to code, and I'm deep in the rabbit hole that you are sending me down. :-)