Home Assistant Community

Convert automation.yaml to nodered ->turn light on sunset and 2xmotion sensor

#1

Hello!

I am starting with nodered trying to convert yaml automations to nodered as training but I am stuck now, maybe you can help me.

I have automations where if my pir sensor and microweave sensor is on and it is night (30min before sunset and 30min before sunrise) turn on light and turn off if there is no movement. There is code:

- alias: Włączenie światła w trakcie nocy
  trigger:
  - platform: state
    entity_id: binary_sensor.pokoj_gniewka
    to: 'on'
  - platform: state
    entity_id: binary_sensor.pokoj_gniewka_2
    to: 'on'
  condition:
    condition: and
    conditions:
    - condition: state
      entity_id: binary_sensor.pokoj_gniewka
      state: 'on'
    - condition: state
      entity_id: binary_sensor.pokoj_gniewka_2
      state: 'on'
    - condition: state
      entity_id:  light.lampka_nad_monitorem
      state: 'off'
    - condition: or
      conditions:
      - condition: sun
        after: sunset
        after_offset: "-00:30:00"
      - condition: sun
        before: sunrise
        before_offset: "-00:30:00"
  action:
    entity_id:  light.lampka_nad_ubraniami
    service: light.turn_on

- alias: Wyłączenie światła przy nie wykryciu ruchu przez 1 min
  trigger:
  - entity_id: binary_sensor.pokoj_gniewka
    platform: state
    to: 'off'
    for:
      minutes: 1
  - entity_id: binary_sensor.pokoj_gniewka_2
    platform: state
    to: 'off'
    for:
      minutes: 1
  condition:
    condition: and
    conditions:
    - condition: state
      entity_id: binary_sensor.pokoj_gniewka
      state: 'off'
    - condition: state
      entity_id: binary_sensor.pokoj_gniewka_2
      state: 'off'
  action:
    entity_id:  light.lampka_nad_ubraniami
    service: light.turn_off

Can somone tell me how do it on nodered? I could leave it that way but i want to be better at it :slight_smile:

#2

Hi!

I’m rally not big at nodered, and I also find my solution when I was browsing forums, but this is working for me:

light.yaml (5.1 KB)

First of all, open it and copy the content to clipboard. After this you can import in nodered from clipboard.

I have only a combined PIR+MW so I have one input but you can add more.
“Kocsibeálló PIR” is the motion sensor. Edit it and use your sensors entity ID.
“Lampa ON” is the Light entity, do the same and change the entity ID.
“ON” is the command to turn it on. If you have a light type entity then you have to change my switch type entity also.
“OFF” is the same but for tur off if there is no more movement.
“Idozito” is the timer, you can set how long you want the light to stay on.
At “naplemente” you can set up the offsets for sunrise and sunset.

I’m sure there are people how have better setup, but it’s enought and working for me.

1 Like