Help with trigger combination

Hello, I am very new at node red. I have been using HA for a while now and since I am not a coder, it seems like a good alternative to yaml.
Anyway, I already lost a few hours trying to do something, I guess, quite simple:

  • I have 2 switches, room lamp and kitchen lamp (shelly´s)
  • I'd like to: switch on room lamp then if I switch off the same room lamp within 2 seconds, kitchen lamp toggles.
    Thanks for any help

Welcome to the forum!

What version of NR are you running?
What version of node.js (both of these can be found on the startup log)
What platform and OS are you using?
When you say you have two switches, do you ean in the flow or are they physical switched?
and last but not least, what have you tried so far?

Ok, I am using ver. 6.03 within home assistant with hass.io.
I have 2 physical switches.
I tried with timers but I do not understand enough of the logic.
Thanks

Ok, I am using ver. 6.03

version 6.03 of what?
What version of Node-RED are you using?
Can you provide your flow?

I installed node red as a component in HA:

Hass.io Add-on: Node-RED
Flow-based programming for the Internet of Things

Add-on version: 6.0.3
You are running the latest version of this add-on.
System: HassOS 1.12 (armv7 / raspberrypi3)
Home Assistant version: 0.104.3
Supervisor version: 195

So far I use a yaml automation to do what I need with a timer and this automation:

Blockquote

  • alias: 'toggler light on'
    trigger:
    platform: state
    entity_id: light.primary
    from: 'off'
    to: 'on'
    action:
    service: timer.start
    entity_id: timer.toggler

  • alias: 'toggler light off'
    trigger:
    platform: state
    entity_id: light.primary
    from: 'on'
    to: 'off'
    condition:
    condition: template
    value_template: "{{ states('timer.toggler') == 'active' }}"
    action:
    service: light.toggle
    entity_id: light.secondary

Blockquote

This sounds like a question you should ask on the Hassio forum

wao, thanks! This is a node red question, not hassio related.

Well what have you tried in Node-RED? What does your flow look like? If you open NR and pull down the hamburger menu on the top right, you'll see the NR version at the bottom. What is it?

Can you share the flow you have so far ? I would guess something like the room lamp feed a 2 sec trigger - sending 1 then 0 - and that feeding a change node to set a flow variable. Then the same switch also feeding a function that checks if the switch is a 0 (ie turned off) and the flow variable is a 1 - then toggle the kitchen lamp.

[{"id":"a86e21ff.e32a5","type":"inject","z":"c4f68fc3.2dd88","name":"on","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":1160,"wires":[["ea2f6bdb.f8dcb8","bfa0b72d.6745e8"]]},{"id":"ea2f6bdb.f8dcb8","type":"switch","z":"c4f68fc3.2dd88","name":"","property":"room","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":290,"y":1200,"wires":[["c31cbb0d.435ee8"]]},{"id":"bfa0b72d.6745e8","type":"trigger","z":"c4f68fc3.2dd88","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"2","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":300,"y":1160,"wires":[["afb0cff6.64905"]]},{"id":"c31cbb0d.435ee8","type":"debug","z":"c4f68fc3.2dd88","name":"use to trigger kitchen","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":500,"y":1200,"wires":[]},{"id":"4fecaa61.b42764","type":"inject","z":"c4f68fc3.2dd88","name":"off","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":1200,"wires":[["bfa0b72d.6745e8","ea2f6bdb.f8dcb8"]]},{"id":"afb0cff6.64905","type":"change","z":"c4f68fc3.2dd88","name":"","rules":[{"t":"set","p":"room","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":1160,"wires":[[]]}]

ver 1.0.3

Thank you so much. This is exactly what I wanted. I uploaded a picture of my flow in case someone needs something like that. Thanks again!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.