# Alexa Node Red to Viera TV

**URL:** <https://discourse.nodered.org/t/alexa-node-red-to-viera-tv/7318>\
**Category:** General\
**Created:** [27 January 2019 23:17 UTC](https://discourse.nodered.org/t/alexa-node-red-to-viera-tv/7318 "2019-01-27T23:17:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgguinne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mgguinne/32/5458_2.png) [@mgguinne](https://discourse.nodered.org/u/mgguinne)\
**Post date:** [27 January 2019 23:17 UTC](https://discourse.nodered.org/t/alexa-node-red-to-viera-tv/7318/1 "2019-01-27T23:17:13Z")

</div>

Hi,

Hoping I can get your help with a simple issue. I have a configured both Alexa and Viera (node-red add-ons) and want to use Alexa to change the volume of my tv.

I know I need the value "bri" but this needs to be sent as a string to the Viera add on. For the life of me, I can't figure out how to send this as a string.

I think one major issue is that the debug request only accepts an object so this means it's very hard to test.

I have exported my config here.

The payload back from alexa for the TV Tv node is:

> Blockquote  
> msg : Object  
> object  
> on: true  
> bri: 3  
> from: "::ffff:10.0.0.x"  
> on\_off\_command: false  
> payload: "on"  
> change\_direction: 0  
> bri\_normalized: 0.03  
> device\_name: "TV"  
> light\_id: "cd9510e8e8e1f"  
> port: 41455  
> \_msgid: "cb14f4b3.94ffd8"

the payload from a standard volume inject is:

> Blockquote  
> msg : Object  
> object  
> \_msgid: "9b6a5a50.2914a8"  
> topic: ""  
> payload: "10"

Flow

> Blockquote  
> [{"id":"b7e668ac.002358","type":"viera write","z":"886ce33a.5e652","name":"setVolume","host":"10.0.0.x","function":"setVolume","x":730,"y":100,"wires":},{"id":"dc6fc9be.67ab18","type":"alexa-local","z":"886ce33a.5e652","devicename":"TV","inputtrigger":false,"x":230,"y":120,"wires":[["ffb17ab2.450068"]]},{"id":"7afcb8af.05aa18","type":"debug","z":"886ce33a.5e652","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":730,"y":140,"wires":},{"id":"ffb17ab2.450068","type":"function","z":"886ce33a.5e652","name":"","func":"return msg.payload[0].bri;","outputs":1,"noerr":0,"x":430,"y":140,"wires":[["7afcb8af.05aa18","b7e668ac.002358"]]}]

I have tried, in a function

1:  
msg.payload = msg.payload[0].bri;  
return msg.payload;

2:  
msg.payload = msg.payload.bri  
return msg.payload;

3:  
return msg.payload[0].bri;

 ![viera1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d872b7a27f754a462322275a7574cc6116686ba9.png)

Example TV config that works comes from:

> **[node-red-contrib-viera](https://flows.nodered.org/node/node-red-contrib-viera)**
>
> Control Panasonic Viera tv with node red

---

<div class="post-metadata">

**Author:** ![mgguinne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mgguinne/32/5458_2.png) [@mgguinne](https://discourse.nodered.org/u/mgguinne)\
**Post date:** [27 January 2019 23:58 UTC](https://discourse.nodered.org/t/alexa-node-red-to-viera-tv/7318/3 "2019-01-27T23:58:40Z")

</div>

Well I solved it, seems it will accept a number type as well. If some can still help with converting to string, I thing that will be helpful later on.

[{"id":"b7e668ac.002358","type":"viera write","z":"886ce33a.5e652","name":"setVolume","host":"10.0.0.x","function":"setVolume","x":730,"y":220,"wires":[]},{"id":"dc6fc9be.67ab18","type":"alexa-local","z":"886ce33a.5e652","devicename":"TV","inputtrigger":false,"x":230,"y":120,"wires":[["dd75f9a5.cb9698"]]},{"id":"7afcb8af.05aa18","type":"debug","z":"886ce33a.5e652","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":730,"y":260,"wires":[]},{"id":"dd75f9a5.cb9698","type":"change","z":"886ce33a.5e652","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"bri","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":120,"wires":[["7afcb8af.05aa18","b7e668ac.002358"]]}] ![viera3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4f6ab404b11675ce1ddf9fd29c7d8c4d17596985.png)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [28 January 2019 06:19 UTC](https://discourse.nodered.org/t/alexa-node-red-to-viera-tv/7318/4 "2019-01-28T06:19:00Z")

</div>

Glad you got it working one thing to note: When using a function you need to return an object

eg

return msg

rather than

return msg.payload

---

<div class="post-metadata">

**Author:** ![mgguinne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mgguinne/32/5458_2.png) [@mgguinne](https://discourse.nodered.org/u/mgguinne)\
**Post date:** [28 January 2019 12:46 UTC](https://discourse.nodered.org/t/alexa-node-red-to-viera-tv/7318/5 "2019-01-28T12:46:53Z")

</div>

Thanks,

I think I have the correct code now, returns a string.

> Blockquote  
> msg.payload = String(msg.bri);  
> return msg;

The key here was to keep the payload object intact.
