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
↔
tom_l
July 16, 2024, 2:51pm
2
1 Like
Jankr:
why doesn’t this work?
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.
tom_l
July 17, 2024, 10:08am
5
The time condition is not enabled:
Jankr:
enabled: false
but as I said earlier it is difficult to help you if you do not format your post correctly.
Tamsy
(Tamsy)
July 17, 2024, 10:40am
6
Jankr:
why doesn’t this work?
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://)
tom_l
July 17, 2024, 12:30pm
8
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://)
tom_l
July 17, 2024, 1:05pm
10
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