Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State Toggle functionality #9

Open
Orgjvr opened this issue Jun 3, 2018 · 4 comments
Open

State Toggle functionality #9

Orgjvr opened this issue Jun 3, 2018 · 4 comments

Comments

@Orgjvr
Copy link

Orgjvr commented Jun 3, 2018

Is there a way to implement a Toggle functionality?

What I mean is if the light is ON, then switch it OFF or if it is OFF then switch it ON.

I tried to implement it by first querying the state and then to request the opposite state. The problem is, that as soon as the new state is implemented, the node which I used to query the current state, acts on the new state and sends the opposite state. Thus creating an endless loop!

My use case is in fact a physical toggle button which the wife wants to press to toggle the state :)

Thanks for a great node.

@soloam
Copy link

soloam commented Sep 26, 2018

I had this exact same problem, what I did was add a flag (trigger = true) before the node that requests the state, after I get a response I check if the trigger is set, when is a automatic trigger that flag is not set, and I ignore the message.

[{"id":"60191714.068958","type":"switch","z":"2077f7db.a8cc48","name":"Node ID","property":"nodeId","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":280,"y":120,"wires":[["9bedbb70.ae26d8"],["840ebdf1.d040a"]]},{"id":"9bedbb70.ae26d8","type":"switch","z":"2077f7db.a8cc48","name":"Child ID","property":"childSensorId","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":460,"y":80,"wires":[["3874706d.6c1e2"]]},{"id":"840ebdf1.d040a","type":"switch","z":"2077f7db.a8cc48","name":"Child ID","property":"childSensorId","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":460,"y":160,"wires":[["8107e40.5f5f12"]]},{"id":"8107e40.5f5f12","type":"yeelight-compat-hue-state","z":"2077f7db.a8cc48","name":"","server":"31a4dbf9.3486b4","x":650,"y":160,"wires":[["dddb3fe4.25cdd"]]},{"id":"3874706d.6c1e2","type":"yeelight-compat-hue-state","z":"2077f7db.a8cc48","name":"","server":"75c54093.00cfb","x":650,"y":80,"wires":[["dddb3fe4.25cdd"]]},{"id":"469a7c44.a69ff4","type":"change","z":"2077f7db.a8cc48","name":"inject","rules":[{"t":"set","p":"inject","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":120,"wires":[["60191714.068958"]]},{"id":"dddb3fe4.25cdd","type":"switch","z":"2077f7db.a8cc48","name":"Inject Check","property":"inject","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":120,"wires":[["1696eeff.781261"]]},{"id":"1696eeff.781261","type":"change","z":"2077f7db.a8cc48","name":"Remove Inject","rules":[{"t":"delete","p":"inject","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":120,"wires":[[]]},{"id":"31a4dbf9.3486b4","type":"yeelight-compat-hue-config","z":"","hostname":"192.168.1.11","port":"55443","name":"Y2"},{"id":"75c54093.00cfb","type":"yeelight-compat-hue-config","z":"","hostname":"192.168.1.10","port":"55443","name":"Y1"}]

This node is very useful, but I really miss a option to no auto trigger (or a separated node to incoming messages and requests) a feedback of errors on the nodes (so that I can retry if a timeout occurs) and the toggle option.

@jpg06
Copy link

jpg06 commented Feb 5, 2019

Hi,
I have the same need as you do: a "toggle" command to change the state light.
I proposed a code change to resolve this and put the code in the "pull request" section
Friendly,
Jean-Paul

@jpg06
Copy link

jpg06 commented Feb 13, 2019

Hi,

it's the first time i really use github for code modify.
I think i found how to do a "pull request" and i hope it is in accordance this the way to do if.

Jean-Paul

@jpg06
Copy link

jpg06 commented Apr 1, 2019

Some extra 'space' will give unsucces travis tool.
Now it is Ok.
What do you think of my "pull request" proposal ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants