Announcement

Collapse
No announcement yet.

NodeRed and Alexa - node-red-contrib-alexa-remote2

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

    #16
    An equally good solution.

    Comment


      #17
      Originally posted by AZweimiller View Post
      I have an SSML structured payload in order to have my Alexa devices do announcements as "whisper".
      How do you do this? My TTS comes in as msg.payload.status. I can whisper hard coded text but don't know enough to get my payload used for the whisper.

      Code:
      <speak>
      <amazon:effect name="whispered">this is a whisper</amazon:effect>
      </speak>
      HS4 Pro on Shuttle NC10U, Win10; Z-NET
      Number of Devices: 1005
      Number of Events: 293

      Plug-Ins: BLLock, DirecTv, EasyTrigger, Honeywell WiFi Thermostat, Marquis monoprice Amp, MeiHarmonyHub, PHLocation2, Pushover 3P, UltraM1G3, rnbWeather, Worx Landroid, Z-Wave

      External applications: Homebridge-homeseer, Geofency, EgiGeoZone.

      Comment


        #18
        Use a function node with something like this right before your Alexa routine node:

        Code:
        msg.payload.payload.type = "ssml";
        msg.payload.payload.text = '<speak><amazon:effect name="whispered">' + msg.payload.status + '</amazon:effect></speak>'

        Comment


          #19
          You could do that with a change node instead of a function node. Most veteran node red users will tell you to avoid the function node if there is a node which does what you need. In messages I have seen, the status is not under payload, which is what msg.payload.status is suggesting. Instead it is just msg.status. If payload is already an object, the setup of the change node is very basic. Set msg.payload.text = payload.status. If it isn't an object, see the second change node in this post. In that I set msg.payload.value to the incoming payload. You can change value to text and oldpayload to status. You can add msg.payload.type once payload is an object so do that last.

          Note that the status may be directly under the msg as msg.status and you may need the status text, or msg.status.text. Test this by using a debug node and display the entire message.

          I do not have an Alexa to test with but if you can copy the full message sent from a debug and give an example of what you need it changed to I can set up a change node to show how to set it up.

          ​​​​​
          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


            #20
            ksum I used this guide: https://forums.homeseer.com/forum/ho...E2%80%9D-guide

            I have no clear understanding of node red

            here is why I think my message is msg.payload.status

            Click image for larger version

Name:	Capture.PNG
Views:	589
Size:	10.9 KB
ID:	1422286

            Here is the flow in question

            Click image for larger version

Name:	flow.PNG
Views:	562
Size:	9.6 KB
ID:	1422287
            HS4 Pro on Shuttle NC10U, Win10; Z-NET
            Number of Devices: 1005
            Number of Events: 293

            Plug-Ins: BLLock, DirecTv, EasyTrigger, Honeywell WiFi Thermostat, Marquis monoprice Amp, MeiHarmonyHub, PHLocation2, Pushover 3P, UltraM1G3, rnbWeather, Worx Landroid, Z-Wave

            External applications: Homebridge-homeseer, Geofency, EgiGeoZone.

            Comment


              #21
              ksum The need to wrap the phrase variable (msg.payload.status in jmaddox example) in the SSML tags is what makes this hard in a regular change node. I don't think a change node can concatenate a variable with a string unless you use something like a JSonata expression. I am happy to be corrected if this is wrong. JSonata isn't exactly newbie friendly so a function node seemed like the easiest way to go.

              There were some issues with my initial reply that may have led to this confusion. I forgot to add the CODE tags to my SSML tags were stripped out. I also forgot to mention that I have the Alexa node set to CUSTOM.

              jmaddox Let's back up and let me ask you this: Is your goal to just have the status text from the HS TTS device always be "whispered" (rather than Spoken or Announced) and always in the Great Room? If so I will experiment in the simplest way to accomplish this and post exact steps. Mine is more complicated because I have the flexibility to speak, announce, whisper to any Alexa device. I can also specify a volume that will override the Alexa device volume for that specific announcement.

              Comment


                #22
                Originally posted by AZweimiller View Post
                jmaddox Let's back up and let me ask you this: Is your goal to just have the status text from the HS TTS device always be "whispered" (rather than Spoken or Announced) and always in the Great Room? If so I will experiment in the simplest way to accomplish this and post exact steps. Mine is more complicated because I have the flexibility to speak, announce, whisper to any Alexa device. I can also specify a volume that will override the Alexa device volume for that specific announcement.
                I'm happy with a simple example. I only have two alexa devices currently, but the firetv one is my test unit for TTS. I had planned to have two flows. One for whispers and one for regular speach. As such I have two virtual devices in HS that feed independent node red flows.

                I would also not mind a more complicated example if you're willing. I could envision a single HS TTS virtual device that passed the alexa name, regular/whispered, and the text to speak.
                HS4 Pro on Shuttle NC10U, Win10; Z-NET
                Number of Devices: 1005
                Number of Events: 293

                Plug-Ins: BLLock, DirecTv, EasyTrigger, Honeywell WiFi Thermostat, Marquis monoprice Amp, MeiHarmonyHub, PHLocation2, Pushover 3P, UltraM1G3, rnbWeather, Worx Landroid, Z-Wave

                External applications: Homebridge-homeseer, Geofency, EgiGeoZone.

                Comment


                  #23
                  A quick lesson on Node Red messages, jmaddox . The image below has a HomeSeer device, a z-wave lamp module in this case, and a debug node. The output option on the debug node is to show the complete msg object. I changed the dim level of the lamp module and the HomeSeer device output the message you see on the right of the image. The msg object shows a topic key and a payload key. You will see these referenced as msg.topic and msg.payload. The payload item is, in this case, an object variable type. It has keys of ref, name, location, location2, value, status, and last_change. So to access the status message we reference this as msg.payload.status.
                  Click image for larger version

Name:	debug1.jpeg
Views:	734
Size:	59.4 KB
ID:	1422453

                  The Debug node can be added anyplace and multiple wires can leave the same point on a node so you can send the message for debug while also sending it on to be processed.

                  This is a picture of the initial flow I would use, with a couple other extra items for my testing.
                  Click image for larger version

Name:	template1.jpeg
Views:	582
Size:	66.0 KB
ID:	1422454

                  I would use two nodes to set what you need. The first is a Change node to set the payload.type to ssml. This is used in the most basic method, as shown here:
                  Click image for larger version

Name:	change1.jpeg
Views:	576
Size:	32.9 KB
ID:	1422456

                  The second node to edit the msg object is a Template node. This will easily put the payload.status inside the tags you need. Set the template to:
                  Code:
                  <speak><amazon:effect name="whispered">{{payload.status}}</amazon:effect></speak>
                  and make the format mustache Template and the output plain text, as shown below.
                  Click image for larger version

Name:	template2.jpeg
Views:	584
Size:	56.5 KB
ID:	1422455

                  I also removed the function node and replace it with a switch node, switching on only 1 value. Base don earlier posts it seems this should be the payload.status but that ma be wrong on my part:
                  Click image for larger version

Name:	switch1.jpeg
Views:	578
Size:	39.3 KB
ID:	1422457

                  Last, if you are sending various messages from different HomeSeer devices, do not copy the change and template nodes of these are the same for all the possibilities. Select them and make a subflow, as explained in Cleaning it up for multiple UI items near the end of this post.

                  Note that you may need to change some pf the property settings as needed, but if you use the debug node, you can hopefully figure out what you need to change.

                  This will import the above nodes so you can open and change them as needed to see if it works for you. Use the 3 line (hamburger) menu at the top right of the node red screen and select Import to paste this JSON into your Node Red flows:
                  Code:
                  [{"id":"881b16a.3b443e8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"e5951d0d.8d906","type":"switch","z":"881b16a.3b443e8","name":"","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"On","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":290,"y":140,"wires":[["9c2b58a9.7fea18"]]},{"id":"699315fa.8fbc2c","type":"hs-device","z":"881b16a.3b443e8","name":"HS TTS Device","device":0,"server":"6d701c13.a6edd4","feature":0,"reportonstartup":false,"x":100,"y":140,"wires":[["e5951d0d.8d906"]]},{"id":"9c2b58a9.7fea18","type":"change","z":"881b16a.3b443e8","name":"","rules":[{"t":"set","p":"payload.type","pt":"msg","to":"ssml","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":60,"wires":[["8f808a15.f8a668"]]},{"id":"b1a1391e.c8e358","type":"debug","z":"881b16a.3b443e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":100,"wires":[]},{"id":"73ae7dca.a5d934","type":"hs-device","z":"881b16a.3b443e8","name":"Family Room Lamp","device":"330","server":"6d701c13.a6edd4","feature":0,"reportonstartup":false,"x":110,"y":60,"wires":[["9c2b58a9.7fea18"]]},{"id":"8f808a15.f8a668","type":"template","z":"881b16a.3b443e8","name":"","field":"payload.text","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<speak><amazon:effect name=\"whispered\">{{payload.status}}</amazon:effect></speak>","output":"str","x":520,"y":120,"wires":[["b1a1391e.c8e358"]]},{"id":"6d701c13.a6edd4","type":"hs-server","z":"","name":"House","host":"192.168.1.10","port":"8008"}]
                  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


                    #24
                    ksum Thank you so much! I'll import the flow and start tinkering.
                    HS4 Pro on Shuttle NC10U, Win10; Z-NET
                    Number of Devices: 1005
                    Number of Events: 293

                    Plug-Ins: BLLock, DirecTv, EasyTrigger, Honeywell WiFi Thermostat, Marquis monoprice Amp, MeiHarmonyHub, PHLocation2, Pushover 3P, UltraM1G3, rnbWeather, Worx Landroid, Z-Wave

                    External applications: Homebridge-homeseer, Geofency, EgiGeoZone.

                    Comment


                      #25
                      ksum I got it working thank you very much. Seeing how to import a flow was also very helpful, it let me import the SSML examples linked to earlier in this thread.

                      Weird issue if I specify which of my alexa devices to use; it wont work.

                      This works just fine.
                      Click image for larger version

Name:	no device.PNG
Views:	564
Size:	6.5 KB
ID:	1422657



                      Nothing happens with this one.
                      Click image for larger version

Name:	device.PNG
Views:	556
Size:	9.1 KB
ID:	1422658
                      HS4 Pro on Shuttle NC10U, Win10; Z-NET
                      Number of Devices: 1005
                      Number of Events: 293

                      Plug-Ins: BLLock, DirecTv, EasyTrigger, Honeywell WiFi Thermostat, Marquis monoprice Amp, MeiHarmonyHub, PHLocation2, Pushover 3P, UltraM1G3, rnbWeather, Worx Landroid, Z-Wave

                      External applications: Homebridge-homeseer, Geofency, EgiGeoZone.

                      Comment

                      Working...
                      X