Hi everyone.
I need some assistant. I have looked and tried the suggestions and I am not getting my automation to turn on lights during only the specified time to occur.
I want the lights to turn on at sunset in my bedroom, triggered by a motion detector.
This should only occur during the time at sunset and before 10pm.
This morning the lights came on and it was 7:15am. Here is an example of my code.
## Master Bedroom Turn on Light based on Motion up to 10:00pm
- alias: Turn on Master Bedroom light when there is movement
trigger:
platform: state
entity_id: binary_sensor.masterbdrpir_192
to: 'on'
condition:
condition: or
conditions: # Or condition used with the sunset and sunrise
- condition: sun
after: sunset
#after_offset: "-00:15:00"
- condition: time
before: '22:00:00'
action:
service: homeassistant.turn_on
entity_id: light.masterbedroomlight_98
data:
brightness: 100
Also, if you want to turn a light on and specify the brightness, you need to use the light.turn_on service instead of the homeassistant.turn_on service. BTW, brightness goes from 0 to 255, whereas brightness_pct goes from 0 to 100.
This isn’t correct. I only use the homeassistant.turn_on / off services in my configuration (because I’m lazy) and it handles all the requests the same.
As for OP - you need an AND condition, not an OR as per @tom_l 's suggestions.
Ok, thanks for the correction. I know I’ve seen issues where in some cases homeassistant.xxx doesn’t work the same as domain.xxx, but maybe I’m remembering incorrectly.
Still, calling light.turn_on is more efficient than calling homeassistant.turn_on, because the latter just has to turn around and call the former. But what’s a few milliseconds between friends?! BTW, if your reasoning is laziness, then that doesn’t make sense, because it takes longer to type homeassistant than light.