biddster / node-red-contrib-wemo-emulator

Why might you want to emulate Wemo? Well I wanted to be able to control my Node-RED Raspberry Pi using my Amazon Echo. The Echo has Wemo support built in so I thought I'd give it a try.
18 stars 8 forks source link

[ENHANCEMENT] Enter On / Off Payload by flow or global variable #30

Open nicedevil007 opened 4 years ago

nicedevil007 commented 4 years ago

Hey biddster,

first I want to thank you for all your work!

I'm on a testrun with your nodes right now and I'm wondering if you would be able to allow as to enter a flow or global variable as the on or off payload.

Why?

We can set a slider for brightness of a lamp or the temperature of a room on the node-red dashboard. This chosen value will be saved to a flow variable and if I input this as the On or Off payload in your node it would be possible to get semi automatic local alexa node for newer devices (echo dot 3 f.e.).

Thank you in advance!

biddster commented 4 years ago

It's a good idea, I'll add it to the list. Fancy submitting a PR?

vepman commented 4 years ago

Hey biddster,

first I want to thank you for all your work!

I'm on a testrun with your nodes right now and I'm wondering if you would be able to allow as to enter a flow or global variable as the on or off payload.

Why?

We can set a slider for brightness of a lamp or the temperature of a room on the node-red dashboard. This chosen value will be saved to a flow variable and if I input this as the On or Off payload in your node it would be possible to get semi automatic local alexa node for newer devices (echo dot 3 f.e.).

Thank you in advance!

Good idea

kravarka commented 1 year ago

Hi,

I am using the node for couple of days, and found that missing such a feature limits automation process a lot. For example, if I turn on manually my lamp, the node does not report that change in Alexa app.

So, it turns out that the code for an input that can change the internal status of the node is rather simple.

I am not a close friend to pull requests, so I am giving my code modifications here, hoping that someone will update them in the main branch or at least use them to modify their local version of the node.

The first change is in index.html, inputs on line 55, has to become 1 from 0.

And the second change is index.js,

the following code has to be inserted at the end, right above the node.on('close', () => { line

node.on('input', function(msg) { if (connection) { if (msg.payload.toLowerCase() == "on") { connection.binaryState = 1; node.status({ fill: 'green', shape: 'dot', text: 'on', }); } if (msg.payload.toLowerCase() == "off") { connection.binaryState = 0; node.status({ fill: 'green', shape: 'circle', text: 'off', }); } } });

With this modification the node will have input and will change its internal state according to the msg.payload.

Input payload should be on or off and the visual status of the module will change accordingly.

I hope this will help someone!