I have been using Home Assistant for a few weeks now and am in the process of setting up my first lights.
Specifically, I want to switch on two lights using a motion detector. This should happen when the sun is behind the horizon and also up to two hours after sunrise and one hour before sunset.
I have already tried a few things with the help of the documentation, but always failed miserably and was always - either in the morning or in the evening - in the dark. Itâs a pity that there is no preview âWhen will be triggeredâ for the conditions in the frontend.
Could someone please help me? The Wife Acceptance Factor is slowly but surely sinkingâŚ
The shutter works When I take out the conditions, the light comes on.
I ask not without reason only for the condition. The conditions at sunrise and sunset are only apparently, as we see, a bit complex to understand, otherwise it would already work after the nice help.
But with pleasure I also publish the whole automationâŚ
alias: Trigger lamps when sun goes down or up
description: 'Lorem Ipsum'
trigger:
- type: motion
platform: device
device_id: 1e7764fa12a988118c0c2ad13d2411a5
entity_id: binary_sensor.lumi_lumi_sensor_motion_aq2_ias_zone
domain: binary_sensor
condition:
- condition: or
conditions:
- condition: sun
after: sunset
after_offset: '-01:00:00'
- condition: sun
before: sunrise
after_offset: '02:00:00'
- condition: state
entity_id: input_boolean.vacation
state: 'off'
action:
- service: light.turn_on
entity_id: light.flurlampen_zha_group_0x0002
data: {}
mode: single
@Remko, I know you said youâre new so welcome to the community, but for the love of God please stop dishing out advice until you know what you are talking about.
In the last 2 hours youâve posted this
trigger:
- platform: state
entity_id: binary_sensor.sensor_bewegung_flur
from: 'false'
to: 'true'
Which will never work as the states for binary sensors are the strings âonâ and âoffâ.
And also this
- condition: sun
before: sunrise
after: sunset
Which will never work because it cannot be both before sunrise and after sunset in the same day, its impossible.
I admire your enthusiasm and desire to help, but all youâre doing is adding confusion.
Excuse me. I indeed was trying to help to keep it simple. Start with one simple rule and I made a small mistake with the on/off or true/false. That is my mind still saying a Boolean variable is true or false and not on or off.
If it is any better I can refrain from trying to help in the future and just ask questions if I have issues myself.
Again sorry for creating confusion. I have removed my posts
I found it easier to create two automations, one for turning on around sunset, and another for turning off around sunrise (each with an offset.) They have no conditions, just triggers. Keeping it simple makes troubleshooting easier, as well as understanding what I did when I come back to it later.
One of my automations looks like this:
- id: lamp_sunset
alias: Lamp On Sunset
trigger:
- event: sunset
platform: sun
offset: -00:15:00
action:
- data:
entity_id:
- switch.my_smart_plug_name
service: switch.turn_on
initial_state: 'false'
mode: single