Hey everyone, I wanted to share my experience with setting up a smart lighting timer using Home Assistant. After a few weeks of trial and error, I finally got it working perfectly! Here’s how I did it:
I started by using a state-icon card on my floorplan to represent my outdoor lights. The goal was to create an icon that would turn the lights on for 10 minutes when tapped. Here’s the code I used:
yaml
- type: state-icon
tap_action:
action: toggle
entity: light.light_garden
style:
top: 15%
left: 13%
border-radius: 60%
text-align: center
background-color: rgba(102, 102, 102, 0.2)
This worked great for manual toggling, but I wanted to add a timer function. I tried using the timer.start service, but it didn’t work as expected. After some research, I realized I needed to adjust the service data to ensure the timer and light entity were properly linked. Here’s the corrected code:
yaml
- type: state-icon
icon: mdi:timer-outline
tap_action:
action: call-service
service: timer.start
service_data:
entity_id: timer.10min
duration: ‘0:10:00’
entity: light.light_garden
style:
top: 15%
left: 20%
border-radius: 60%
text-align: center
background-color: rgba(102, 102, 102, 0.2)
The key was ensuring the timer entity (timer.10min) and the light entity (light.light_garden) were correctly referenced in the service data. I also made sure the timer duration was set to 10 minutes ('0:10:00'). Now, when I tap the timer icon, the lights turn on for exactly 10 minutes before turning off automatically.
This setup has been a game-changer for me, especially for outdoor lighting. It’s perfect for welcoming guests or ensuring my garden is lit during evening walks. I hope this guide helps anyone else looking to add a timer function to their smart lights!
Happy automating! ![]()