Turn on lights when I arrive at home

Hi guys,

New to the home automation community! I’m trying to set up my first automation but it’s not working unfortunately. What I want is when it’s dark and I arrive home, the light in the hall (Hue) is automatically turned on. When I come home, nothing happens. Here is the YAML:

alias: Light on upon arrival
description: Turns on the light in the hall when I arrive.
trigger:
  - platform: zone
    entity_id: person.jos_d
    zone: zone.home
    event: enter
condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
  - condition: device
    type: is_off
    device_id: 647d1ab8b39a3c55f22f719c6fc17eb2
    entity_id: 94ff322dbc127f161bbb1aab494af707
    domain: light
action:
  - service: light.turn_on
    metadata: {}
    data:
      rgb_color:
        - 255
        - 255
        - 0
    target:
      device_id: 647d1ab8b39a3c55f22f719c6fc17eb2
mode: single

Thank you in advance for any support, appreciate it!

Jos

Have you tried it without the second condition? If the light is already on, turning it on again isn’t going to make any difference.

If you have created the automation via the UI then you should be able to look at the automation trace and get some clue as to why it isn’t working.

Thanks for the help so far guys! I indeed noticed in the automation trace that something is off with my mobile device. It is connected but I just went away to another city and it still shows in the logbook that I’ve been at home for the entire time. Before I left, I tried logging out and back in on my mobile app (was a tip I read somewhere) but that didn’t help. Any clue why HA doesn’t detect my phone leaving the zone?

I am trying to set up the same thing. My detection is working but can’t seem to the sun condition to pass when I test it.

For your detection, have you looked in the companion app on your phone to make sure your beacon sensor is on?

Hi Anj,

Could you guide me how//where to check this setting? All Google is giving me is iBeacon results. Thank you!

Do you have nabucasa subscription? If so, open the HA app on your phone, go to settings then to “Companion app”, then go to manage sensors and then check your geolocations to make sure it is enabled.

Also, the geolocation sensor is useful as the entity will show you where the phone has traveled and its present location. For instance, you can set a work zone, once you enter the zone you can have HA trigger something on or off once in the zone. Or flash the lights once your kids enter the school zone. And, if you lose your phone, you can track its location through the desktop HA.