Announcement

Collapse
No announcement yet.

Control a virtual switch in different rooms using the same phrase?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    Check this out, it describes how to communicate with HS nodes.

    https://flows.nodered.org/node/node-...ntrib-homeseer

    Controlling a Device


    To control a device the node needs to receive on its input, a message with msg.topic set to control and either msg.payload.value property set to the control value to use, or the msg.payload.status property set to the control text status to use.


    Comment


      #32
      OK, but how do I connect the inject node to the Route sequence?

      Comment


        #33
        Originally posted by pcgirl65 View Post

        I don't understand what you mean by set msg.top? Is that instead of msg.payload.value?
        It's just a typo : msg.top? = msg.topic


        Eman.
        TinkerLand : Life's Choices,"No One Size Fits All"

        Comment


          #34
          ksum here is the debug log for the Contextual Routine. In this debug, I spoke "I'm reading" and Alexa beeped at me and then nothing happened.

          {"data":{"_disambiguationId":null,"activityStatus":"SUCCESS" ,"creationTimestamp":1603977024545,"description":"{"summary" :"alexa i'm reading","firstUtteranceId":"A3S5BH2HU6VAYF:1.0/2020/10/29/13/G090L91174260WQM/10:23::TNIH_2V.43909247-01d9-49f7-9c91-070848f0f30eZXV/0","firstStreamId":"A3S5BH2HU6VAYF:1.0/2020/10/29/13/G090L91174260WQM/10:23::TNIH_2V.43909247-01d9-49f7-9c91-070848f0f30eZXV"}","domainAttributes":null,"domainType":null ,"feedbackAttributes":null,"id":"AR0JXH2ZEIIOP#1603977024545 #A3S5BH2HU6VAYF#G090L91174260WQM","intentType":null,"provide rInfoDescription":null,"registeredCustomerId":"AR0JXH2ZEIIOP ","sourceActiveUsers":null,"sourceDeviceIds":[{"deviceAccountId":null,"deviceType":"A3S5BH2HU6VAYF","seria lNumber":"G090L91174260WQM"}],"utteranceId":"A3S5BH2HU6VAYF:1.0/2020/10/29/13/G090L91174260WQM/10:23::TNIH_2V.43909247-01d9-49f7-9c91-070848f0f30eZXV","version":1},"description":{"summary":"alex a i'm reading","firstUtteranceId":"A3S5BH2HU6VAYF:1.0/2020/10/29/13/G090L91174260WQM/10:23::TNIH_2V.43909247-01d9-49f7-9c91-070848f0f30eZXV/0","firstStreamId":"A3S5BH2HU6VAYF:1.0/2020/10/29/13/G090L91174260WQM/10:23::TNIH_2V.43909247-01d9-49f7-9c91-070848f0f30eZXV"},"deviceSerialNumber":"G090L91174260WQM","n ame":"Living Room Echo Dot","deviceType":"A3S5BH2HU6VAYF","deviceAccountId":null,"c reationTimestamp":1603977024545,"activityStatus":"SUCCESS"," domainAttributes":null,"destinationUserId":"AR0JXH2ZEIIOP"}

          Comment


            #35
            Here is a flow which will control a HomeSeer device based on Alexa hearing the word "reading" and the specific Alexa unit hearing the device. You will replace the left hand inject node with your Alexa node which receives the your receiving message.
            Flow Code
            Code:
            [{"id":"2b720ce0.8b6e94","type":"tab","label":"PCGirl65","disabled":false,"info":""},{"id":"62246945.9ab4c8","type":"inject","z":"2b720ce0.8b6e94","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"data\":{\"_disambiguationId\":null,\"activityStatus\":\"SUCCESS\",\"creationTimestamp\":1603977024545,\"description\":\"{\\\"summary\\\" :\\\"alexa i'm reading\\\",\\\"firstUtteranceId\\\":\\\"A3S5BH2HU6VAYF:1.0/2020/10/29/13/G090L91174260WQM/10:23::TNIH_2V.43909247-01d9-49f7-9c91-070848f0f30eZXV/0\\\",\\\"firstStreamId\\\":\\\"A3S5BH2HU6VAYF:1.0/2020/10/29/13/G090L91174260WQM/10:23::TNIH_2V.43909247-01d9-49f7-9c91-070848f0f30eZXV\\\"}\",\"domainAttributes\":null,\"domainType\":null,\"feedbackAttributes\":null,\"id\":\"AR0JXH2ZEIIOP#1603977024545#A3S5BH2HU6VAYF#G090L91174260WQM\",\"intentType\":null,\"providerInfoDescription\":null,\"registeredCustomerId\":\"AR0JXH2ZEIIOP \",\"sourceActiveUsers\":null,\"sourceDeviceIds\":[{\"deviceAccountId\":null,\"deviceType\":\"A3S5BH2HU6VAYF\",\"serialNumber\":\"G090L91174260WQM\"}],\"utteranceId\":\"A3S5BH2HU6VAYF:1.0/2020/10/29/13/G090L91174260WQM/10:23::TNIH_2V.43909247-01d9-49f7-9c91-070848f0f30eZXV\",\"version\":1},\"description\":{\"summary\":\"alex a i'm reading\",\"firstUtteranceId\":\"A3S5BH2HU6VAYF:1.0/2020/10/29/13/G090L91174260WQM/10:23::TNIH_2V.43909247-01d9-49f7-9c91-070848f0f30eZXV/0\",\"firstStreamId\":\"A3S5BH2HU6VAYF:1.0/2020/10/29/13/G090L91174260WQM/10:23::TNIH_2V.43909247-01d9-49f7-9c91-070848f0f30eZXV\"},\"deviceSerialNumber\":\"G090L91174260WQM\",\"name\":\"Living Room Echo Dot\",\"deviceType\":\"A3S5BH2HU6VAYF\",\"deviceAccountId\":null,\"creationTimestamp\":1603977024545,\"activityStatus\":\"SUCCESS\",\" domainAttributes\":null,\"destinationUserId\":\"AR0JXH2ZEIIOP\"}","payloadType":"json","x":90,"y":80,"wires":[["590a624b.36f6dc"]]},{"id":"590a624b.36f6dc","type":"switch","z":"2b720ce0.8b6e94","name":"Switch setting us up for Multiple Future Alexa Routines","property":"payload.description.summary","propertyType":"msg","rules":[{"t":"cont","v":"reading","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":280,"y":140,"wires":[["e919bb72.d60128"]]},{"id":"e919bb72.d60128","type":"change","z":"2b720ce0.8b6e94","name":"Status - Control","rules":[{"t":"set","p":"alexaPayload","pt":"msg","to":"payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload.status","pt":"msg","to":"On","tot":"str"},{"t":"set","p":"announce","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":180,"wires":[["5065036a.35de4c"]]},{"id":"5065036a.35de4c","type":"switch","z":"2b720ce0.8b6e94","name":"Where am I Reading","property":"alexaPayload.name","propertyType":"msg","rules":[{"t":"cont","v":"Living Room","vt":"str"},{"t":"cont","v":"Bedroom","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":520,"y":240,"wires":[["729bb1b0.015ab","7365ad20.75af64"],["721bf858.994408"]]},{"id":"729bb1b0.015ab","type":"hs-device","z":"2b720ce0.8b6e94","name":"","device":"27","server":"6d701c13.a6edd4","feature":0,"reportonstartup":false,"x":720,"y":180,"wires":[["86f18748.594928"]]},{"id":"86f18748.594928","type":"switch","z":"2b720ce0.8b6e94","name":"","property":"announce","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":220,"wires":[["638f8300.808d7c","29a28c5c.be0144"]]},{"id":"29a28c5c.be0144","type":"debug","z":"2b720ce0.8b6e94","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1010,"y":260,"wires":[]},{"id":"721bf858.994408","type":"hs-device","z":"2b720ce0.8b6e94","name":"","device":"31","server":"6d701c13.a6edd4","feature":0,"reportonstartup":false,"x":710,"y":280,"wires":[["86f18748.594928"]]},{"id":"638f8300.808d7c","type":"alexa-remote-routine","z":"2b720ce0.8b6e94","name":"","account":"","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"jsonata","value":"\"Lighting control in the \" & msg.alexaPayload.name & \" is now \" & msg.payload.status"},"devices":{"type":"msg","value":"alexaPayload.name"}}},"x":1040,"y":180,"wires":[[]]},{"id":"7365ad20.75af64","type":"debug","z":"2b720ce0.8b6e94","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":240,"wires":[]},{"id":"6d701c13.a6edd4","type":"hs-server","z":"","name":"House","host":"192.168.1.10","port":"8008"}]

            Flow Image
            Click image for larger version

Name:	hs3.png
Views:	419
Size:	31.1 KB
ID:	1429702

            Description
            The Inject node is a place holder where I injected your debug information from your Alexa output. Connect the rest of this flow to that output and remove the Inject node.

            The next node is a Switch node and currently switches on one item. When Alexa hears any statement containing the word "reading" this switch will pass the message to the rest of the flow. This is set for future Alexa routines. If you have multiple Alexa receiving nodes each one will be triggered every time Alexa hears anything. This switch allows you to filter on the word "reading" but also allows you to add other filters in the future and keep all Alexa routines running off one receiving node.

            Next we use a Change node to do a few items:
            Save msg.payload coming from Alexa to msg.alexaPayload so we can use it later in the flow as it is overwritten by later nodes.
            1. Delete the current msg.payload just to clean it up.
            2. Set msg.topic to "control" so we are ready to control a HomeSeer device.
            3. Set msg.payload.status to "On" which is used to set the HomeSeer device's Status to "On" If the HomeSeer device does not have a status of On/Off you may need to change this. I am assuming your virtual device is On or Off.
            4. Set msg.announce to a boolean of true so the flow can determine if it should speak a reply or not. This will keep speakers from speaking if the Homeseer device is changed via another means.
            Now a Switch node allows us to direct the flow to the appropriate HomeSeer device based on which Alexa device heard the request. We are switching on msg.alexaPayload.name. Edit this to add an item for each room/Alexa device. Add a corresponding HomeSeer device node and edit the two here to match your setup.

            From the HomeSeer devices we come back to a single switch node. This and the rest of the flow are only if you desire a confirmation of the flow completion. This look sto see if msg.announce is true. If you change the HomeSeer device from a different interface or method, then the flow is triggered from the appropriate HomeSeer device node. This will mean the payload coming into this switch only has the items passed by HomeSeer and therefore does not have msg.announce at all, effectively stopping the flow unless it was initiated from earlier in the chain.

            An Alexa routine node is then used to send a request to speak a confirmation statement to the same device which heard the request. That statement is a JSONata expression
            Code:
            "Lighting control in the " & msg.alexaPayload.name & " is now " & msg.payload.status
            which uses the Alexa device to announce the room and the paayload returned from HomeSeer to state if lighting control is On or Off.

            You could make some modifications and use the phrase "Alexa, I'm done reading" to then turn the HomeSeer devices Off and announce that they are off. Take a shot at doing that and let's see where you get. As a challenge, I could do this with 2 additional nodes.
            Karl S
            HS4Pro on Windows 10
            1070 Devices
            56 Z-Wave Nodes
            104 Events
            HSTouch Clients: 3 Android, 1 iOS
            Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

            Comment


              #36
              ksum This is fantastic! Thanks so much! I have read through your explanation and I am trying to learn as I go. I will try to do the OFF part. I am thinking that I have to add to the first switch to be able to determine "done reading". So I would need to add contains: done reading and maybe reading off. How do I do this so that if the exact phrase isn't spoken it will still work?

              Then I think I have to add another 'status control' node like the first one but with the msg.payload.status set to Off. Is this correct? The rest should run as usual.

              Comment


                #37
                That is correct, pcgirl65 I would insert a Switch node after the Status Control change node. This switch looks to see if the spoken Alexa phrase contains the word "done" or "finished" or any other word you may use to say you have stopped reading. The very last option is "otherwise" so now you have anything else passing. Since you have already set the flow up to send "On" to the HomeSeer device, we just need to use these triggers to go to a change node to change msg.payload.status to "Off" So take each output which correlates to matching a "I'm done reading" statement and connect them all to the one change node to set the status to "Off." Connect it into the "Where am I Reading" switch node, and also connect the "otherwise" into the "Where am I Reading" node.

                So with this, you first filter for the word "reading" If it is spoken at ANY TIME to Alexa, this flow will continue. "What is Mr Rogers reading" will trigger the flow. Then, if one of your I've-stopped-reading key words is in the statement it will turn Off the virtual device in HomeSeer and tell you it has. Otherwise it will turn it on and tell you it is on. So set your filtering words as precise as you need but remember that the more precise you are the more precise you need to speak the command.
                Karl S
                HS4Pro on Windows 10
                1070 Devices
                56 Z-Wave Nodes
                104 Events
                HSTouch Clients: 3 Android, 1 iOS
                Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                Comment


                  #38
                  Will there be a problem if "reading" is used for turning On the switches and also "done reading" is used to turn Off the switches seeing as "reading is in both"?

                  Comment


                    #39
                    With the way I described in post 37, your first switch looks for the word "reading" and passes the message down the flow if it exists. We then use the same Change node, which sets us up to turn the virtual device on, as well as doing a few other things. Now we go to a new switch node and look for the keywords that you are finished. So yes, reading is in both and passes the first switch. The second switch says "Go to this new change node if you have one of these words in you as well: done, stop, finished. Otherwise go down to a switch which sends you to control the proper device. The new change node just changes the "On" we set earlier to "Off" for controlling the HomeSeer device, and then sends us to the switch which sends us to control the proper HomeSeer device.

                    Does this make sense? We look for "reading" and set things up to turn on the reading mode. We then look for "done" and set only variable which needs to be changed to instead turn off the reading mode if we find the word "done" but leave the variable alone otherwise.

                    I would add more than "done" to the new switch node. I would probably include "stopped" and "finished" at a minimum. Each would have an output and you wire them all to the new change node to set msg.payload.status to "Off" so that you can be free with your speach: "I'm

                    The two nodes with a red check below are added to do this.
                    Click image for larger version

Name:	HS2.png
Views:	145
Size:	29.7 KB
ID:	1429790
                    Attached Files
                    Karl S
                    HS4Pro on Windows 10
                    1070 Devices
                    56 Z-Wave Nodes
                    104 Events
                    HSTouch Clients: 3 Android, 1 iOS
                    Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                    Comment


                      #40
                      I am looking at this on my phone ATM bit I see what you are saying. I was thinking that I used the same first switch node and added the done, finished,etc to it and then joined it to the new change mode. I will look at this when I get home. Thanks for all your help!

                      Comment


                        #41
                        I think this is right. However, when I test this out, sadly it isn't working. I say "Alexa, I'm reading" and she just beeps at me. It doesn't seem to be getting past the first switch. Should the Delete.msg.payload be in there?

                        Click image for larger version

Name:	Reading Modejpg.jpg
Views:	142
Size:	45.7 KB
ID:	1429865

                        Click image for larger version

Name:	Reading switch.jpg
Views:	135
Size:	61.9 KB
ID:	1429866

                        Comment


                          #42
                          In the Status control for Done Reading switch node, did you include an otherwise option? That should be the last option and it should connect to the Where am I Reading node. You add another option and change msg to otherwise. My apologies for leaving that out of the later descriptions. I'm on my phone but can get an image later if needed.
                          Karl S
                          HS4Pro on Windows 10
                          1070 Devices
                          56 Z-Wave Nodes
                          104 Events
                          HSTouch Clients: 3 Android, 1 iOS
                          Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                          Comment


                            #43
                            Like this?

                            Click image for larger version

Name:	Reading switch.jpg
Views:	208
Size:	78.8 KB
ID:	1429887

                            Click image for larger version

Name:	Reading Modejpg.jpg
Views:	203
Size:	51.2 KB
ID:	1429888

                            Comment


                              #44
                              Yes. This way starting to read has a place to go.
                              Karl S
                              HS4Pro on Windows 10
                              1070 Devices
                              56 Z-Wave Nodes
                              104 Events
                              HSTouch Clients: 3 Android, 1 iOS
                              Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                              Comment


                                #45
                                Still not working. Doesn't seem to get past the Status Control ON switch. At least that is what I think. When I move the debug node onto the Where am I Reading node, it doesn't display anything in the debug log. When I attach it onto the Status Control On switch, I can see status On in the debug console twice.

                                Comment

                                Working...
                                X