Hi, I’m looking for a way to turn a light on when I approach the house when it’s dark. I’ve got Tradfri lights which can be controlled by Hassio, all that part is set up and working fine.
I’d like some way of turning a light on as I approach the house, maybe by GPS or when I connect to wifi?
You can use the Owntracks app which works on both iOS and Android
For this to work you will also need to setup an MQTT server.
Owntracks is the more complex approach but easy to setup with MQTT and works the best for me.
If not you can do it by detecting when you connect to wifi, look for your router brand on the components page and see if its supported. You then just need to write an automation to tell HA what to do once it detects you have connected to wifi.
I do this using the unifi platform and a sensor on the front door.
Trigger on front door opening.
Conditions are after sunset and nobody home or has been home less than 2 minutes (since wifi can connect before we open the door.).
EDIT: Unifi is more reliable then owntracks for me
Thanks for the reply. I also have a Ring doorbell which can sense motion, I wonder if I could set it so when the ring detects motions it turns on a light?
I dont know much about the Ring system in HA but so long as HA can detect the motion then yes you could create an automation in HA to turn on a light when it detects motion from your ring.
But that would mean anyone coming up to your door will turn on your lights, do you really want that?
Good point. I do want the light to come on for anyone as I want it to act a bit like a security light.
Looks like Ring has a component in HA so I’ve set it up so it records motion and have used an automation so it turns the lights on - success!
The second part to this is turning the light off after 30 seconds. Is there any way to modify the automation script so it turns off again after a specified time? Below is the script I used
- alias: Hall 4 Light on with motion
entity_id: light.hall_4
service: light.turn_on
condition:
- after: sunset
condition: sun
id: '1515148612637'
trigger:
- entity_id: binary_sensor.ring_front_door_motion
platform: state
I don’t think you can have alias in an action, the action does not need a ‘-’ and any list of items needs the ‘-’ as I specified above. Trouble is you are using the inbuilt automation editor and I don’t I just code mine directly in the yaml file. It also looks to me as if your action is not aligned with the condition, id and trigger, however when you get rid of the ‘-’ in front of the action it should then line up correctly.
@matt666 The automation editor just messes everything up with yaml. Read through this and you’ll get an idea of what the structure needs to be. If you’re really stuck, I’ll help out.