Time not working

why doesn’t this work? sensor on at sunset and on at sunrise

<_>
alias: Test
description: “”
trigger:

  • type: motion
    platform: device
    device_id: 956efcc577a16b3572140204e3c95f9b
    entity_id: 343bc6b4e33175ffed83ccbe988528aa
    domain: binary_sensor
    for:
    hours: 0
    minutes: 0
    seconds: 30
    condition:
    action:
  • if:
    • condition: time
      after: “21:00:00”
      before: “07:00:00”
      weekday:
      • mon
      • tue
      • wed
      • thu
      • fri
      • sat
      • sun
        then:
        enabled: false
  • type: turn_on
    device_id: 20db998ca5b1587efa43be1bfab09790
    entity_id: c16d7a5dfdad713dbb04393075f6ac35
    domain: light
    flash: short
  • delay:
    hours: 0
    minutes: 0
    seconds: 30
    milliseconds: 0
  • service: notify.mobile_app_sm_g998b
    data:
    message: "Indringer "
  • type: turn_off
    device_id: 20db998ca5b1587efa43be1bfab09790
    entity_id: c16d7a5dfdad713dbb04393075f6ac35
    domain: light
    mode: single

Please format your post correctly. See: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

1 Like

It looks like the If/Then action is disabled… but it is very difficult to tell what is going on without proper formatting, an explanation of what your goal is, and details about what isn’t working the way you expected.

Hello, the sensor is only intended to work between 9 p.m. and 7 a.m., or between sunset and sunrise.

The time condition is not enabled:

but as I said earlier it is difficult to help you if you do not format your post correctly.

To format your code correctly is not that hard, @Jankr:

Simply highlight the code block you pasted into the textbox and hit the </> button above.

[alias: Test
description: “”
trigger:

  • type: motion
    platform: device
    device_id: 956efcc577a16b3572140204e3c95f9b
    entity_id: 343bc6b4e33175ffed83ccbe988528aa
    domain: binary_sensor
    for:
    hours: 0
    minutes: 0
    seconds: 30
    condition:
    action:
  • if:
    • condition: time
      after: “21:00:00”
      before: “07:00:00”
      weekday:
      • mon
      • tue
      • wed
      • thu
      • fri
      • sat
      • sun
        then:
        enabled: false
  • type: turn_on
    device_id: 20db998ca5b1587efa43be1bfab09790
    entity_id: c16d7a5dfdad713dbb04393075f6ac35
    domain: light
    flash: short
  • delay:
    hours: 0
    minutes: 0
    seconds: 30
    milliseconds: 0
  • service: notify.mobile_app_sm_g998b
    data:
    message: "Indringer "
  • type: turn_off
    device_id: 20db998ca5b1587efa43be1bfab09790
    entity_id: c16d7a5dfdad713dbb04393075f6ac35
    domain: light
    mode: single](https://)

Try again.

Or

We are not telling you to do this to be difficult. It is actually really hard to help you if you don’t format your post correctly.

And do not post a screen-shot of text. That is even worse. We cant edit a screen-shot.

2 Likes

[alias: Test
description: “”
trigger:

  • type: motion
    platform: device
    device_id: 956efcc577a16b3572140204e3c95f9b
    entity_id: 343bc6b4e33175ffed83ccbe988528aa
    domain: binary_sensor
    for:
    hours: 0
    minutes: 0
    seconds: 30
    condition:
    action:
  • if:
    • condition: time
      after: “21:00:00”
      before: “07:00:00”
      weekday:
      • mon
      • tue
      • wed
      • thu
      • fri
      • sat
      • sun
        then:
        enabled: false
  • type: turn_on
    device_id: 20db998ca5b1587efa43be1bfab09790
    entity_id: c16d7a5dfdad713dbb04393075f6ac35
    domain: light
    flash: short
  • delay:
    hours: 0
    minutes: 0
    seconds: 30
    milliseconds: 0
  • service: notify.mobile_app_sm_g998b
    data:
    message: "Indringer "
  • type: turn_off
    device_id: 20db998ca5b1587efa43be1bfab09790
    entity_id: c16d7a5dfdad713dbb04393075f6ac35
    domain: light
    mode: single](https://)

Stop posting the same unformatted text over and over again.

Listen to what we told you repeatedly or we can not help you and I will close the topic.

Also why did you mark my post as the solution?

Get rid of the If/Then action, put the Time condition in the condition block (“And If” section in the Automation editor).

Thank you for your suggestion. I corrected the script and everything works fine now. See below the final code.

alias: Sensor schuur activeerd lamp
description: ""
trigger:
  - type: motion
    platform: device
    device_id: 956efcc577a16b3572140204e3c95f9b
    entity_id: 343bc6b4e33175ffed83ccbe988528aa
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
condition:
  - condition: time
    after: "21:00:00"
    before: "07:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
action:
  - type: turn_on
    device_id: 20db998ca5b1587efa43be1bfab09790
    entity_id: c16d7a5dfdad713dbb04393075f6ac35
    domain: light
    flash: short
  - service: notify.mobile_app_sm_g998b
    data:
      message: "Indringer "
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - type: turn_off
    device_id: 20db998ca5b1587efa43be1bfab09790
    entity_id: c16d7a5dfdad713dbb04393075f6ac35
    domain: light
mode: single
1 Like