Automation light wc

Good morning.
Can anyone see what’s going wrong? the toilet lamp does turn on. only this one goes out quite quickly. but then no longer turns on during movement. so if someone sits still for a long time, he sees no movement and the lamp goes out. but I can now also set it so that if the sensor detects no movement, it will dimly turn off. and the person is therefore triggered to move?

alias: Wc lamp
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.wc_motion
    to: "on"
    id: Motion detected
  - platform: state
    entity_id:
      - binary_sensor.wc_motion
    to: "off"
    for:
      hours: 0
      minutes: 4
      seconds: 0
condition: []
action:
  - if:
      - condition: trigger
        id:
          - Motion detected
      - condition: sun
        before: sunset
        after: sunrise
    then:
      - service: light.turn_on
        data:
          brightness_pct: 40
        target:
          entity_id:
            - light.wc
    else:
      - service: light.turn_off
        data:
          transition: 60
        target:
          entity_id: light.wc
  - if:
      - condition: trigger
        id:
          - Motion detected
      - condition: sun
        after: sunset
      - condition: time
        before: "23:00:00"
    then:
      - service: light.turn_on
        data:
          brightness_pct: 30
        target:
          entity_id: light.wc
    else:
      - service: light.turn_off
        data:
          transition: 60
        target:
          entity_id: light.wc
  - if:
      - condition: trigger
        id:
          - Motion detected
      - condition: time
        after: "23:00:00"
        before: "06:00:00"
    then:
      - service: light.turn_on
        data:
          brightness_pct: 15
        target:
          entity_id: light.wc
    else:
      - service: light.turn_off
        data:
          transition: 60
        target:
          entity_id: light.wc
  - if:
      - condition: trigger
        id:
          - Motion detected
      - condition: time
        after: "06:00:00"
      - condition: sun
        before: sunrise
    then:
      - service: light.turn_on
        data:
          brightness_pct: 30
        target:
          entity_id: light.wc
    else:
      - service: light.turn_off
        data:
          transition: 60
        target:
          entity_id: light.wc
mode: single

What does the trace tell you?

I am also new to the world of home assistant. I have been working with homey for a while now. That’s the only reason I sometimes have doubts about whether he is doing the right things. That’s why I started looking at home assistant.

So I have no idea what exactly you mean?

Did you click and read the page I linked you to?

It explains how to trace your automation for troubleshooting.

yes I did.
But because I am new to home assistant, I don’t yet understand where to find something to solve it.
That’s why I ask.

Try reading the troubleshooting guide again, it explains everything you need to know.

Here is an example of what works for me, I use triggers.

description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.sensor_toilet_beweging
    from: "off"
    to: "on"
    id: wc beweging
  - platform: state
    entity_id:
      - binary_sensor.sensor_toilet_beweging
    from: "on"
    to: "off"
    for:
      hours: 0
      minutes: 1
      seconds: 0
    id: wc geen beweging
condition: []
action:
  - if:
      - condition: and
        conditions:
          - condition: trigger
            id:
              - wc beweging
    then:
      - service: light.turn_on
        metadata: {}
        data:
          brightness_pct: 30
        target:
          area_id: toilet
    else:
      - service: light.turn_off
        metadata: {}
        data: {}
        target:
          area_id: toilet

It’s great that you want to help but it is not much use unless you format it properly, see: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371

Noted and changed. Hopefully this is better.

1 Like