I am trying to make my light turn on automatically if it gets dark enough with the condition that I am at home.
This is my first automation and there are a lot of options in witch I’m not sure what to put.
This si my YML
alias: Lights
description: Turn un lights. when it's dark
trigger:
- type: value
platform: device
device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
entity_id: sensor.light
domain: sensor
below: 1000
condition:
- condition: state
entity_id: device_tracker.iphone
state: home
attribute: gps_accuracy
condition: and
conditions:
- condition: device
type: is_off
device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
entity_id: switch.xxxxxxxxxxxxxxxxxxxx_x
domain: switch
action:
- type: turn_on
device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
entity_id: switch.xxxxxxxxxxxxxxxxxxxx_x
domain: switch
mode: restart
Can someone tell me if this is going to work?
I am using a Smart Life light and a BH1750 sensor with ESPHome
The gps_accuracy attribute is more likely to be a number (like 65) than home. I think you want to delete the whole attribute: gps_accuracy line unless you had some other use for it, such as in a separate numeric_state condition. The state of the device_tracker entity is the current zone (or not_home), and that appears to be what you’re interested in.