In this articole that im planning to make as short as passible im gonna share with you guys 5 automations ideas that i find very useful.
Home Assistant as is allows integrations from different vendors and manual control of devices.
If you want to do everything with a voice command of with the push of a software button i guess this article is not for you.
- How you can automate things in Home Assistant?
- 1. Cycle through multiple light scenes with just one button press
- 2.Turn off power to the phone after it get to 85% charge
- 3.NFC tag to trigger automation
- 4.Turn on the light next to the fridge when you open the door
- 5.Turn on my speakers after the computer is on
But…if you want to leverage the true power of home automations i guess you have to make your tasks a little bit less physicality involved (thats why software like Home Assistant exists in the first place).
How you can automate things in Home Assistant?
Basically Home Assistant has two main ways in witch you can create automations.
The first method is using the Home Assistant Automations interface.
You can find that in Settings / Automations & scenes
Or you can use a custom integration like Node Red.
From my experience Node Red caters towards more advanced users who already know the platform or have really complex automations that cannot be achieved inside HASS (this occasions are somewhat rare)
I will show my automation examples inside Home Assistant, in the form of yaml so you can copy/paste the automation with ease.
Please note that in order for the automations to work, you must change the entities.
1. Cycle through multiple light scenes with just one button press
Next to my desk i have an Ikea on/off button that has only a few actions that i can use it for automations.
So i started to wonder the internet until i found a solution.
First you need to create a Counter inside of Settings / Devices & Services / Helpers hit the blue + Create Helper.
Here set the minimum value to 0 and the initial value to 0 and set the maximum value of the counter (the maximum value determines the maximum number of scenes that you want to trigger with the button).
Also another thing is to make sure that the Step size is set to 1.
Now to create the automation, first we must select the button that we can use to trigger the counter.
alias: "Cameră - Buton birou 1 apăsare "
description: Trigger counter
trigger:
- platform: device
domain: mqtt
device_id: 52142998e3c80bda79a8338abbb3b164
type: action
subtype: "on"
discovery_id: 0x943469fffe5d7dd3 action_on
condition: []
action:
- service: counter.increment
data: {}
target:
entity_id: counter.contor_buton_birou
mode: single
And create another automation to define the trigger for the scene. Then duplicate it and change the counter increments (ex: from 0 to 1 into 1 to 2 and so on) action/actions that you want the counter to trigger.
alias: Cameră - buton birou counter 1 Chillout
description: ""
trigger:
- platform: state
entity_id:
- counter.contor_buton_birou
from: "0"
to: "1"
condition: []
action:
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
- service: switch.turn_off
data: {}
target:
entity_id: switch.ceiling_light
- service: light.turn_on
data:
color_temp: 500
brightness_pct: 90
target:
entity_id:
- light.bed_lamp
- light.philips_bloom
- light.lamp
- service: script.computer_led_on
data: {}
- service: light.turn_on
data:
color_temp: 500
brightness_pct: 6
target:
entity_id: light.desk_lamp
mode: single
2.Turn off power to the phone after it get to 85% charge
Its important to preserve the battery health of your mobile phone in order to prolong its life.
One of the most efficient ways is to charge the device with 5V 1A/2A MAX and to unplug it from the charger at 80 to 85%.
But its a pain to unplug your phone at exact 80% battery! You can set a notification i guess but what if youre not in the room or at home?
I made a simple automation that turns off a Tuya USB relay when the phone reaches 85%.
If you are interested in the relay, you can find it here.
alias: Telefon - încărcat la 85%
description: ""
trigger:
- type: battery_level
platform: device
device_id: 9aa51aa14bbeee4d823df5f0f530a44e
entity_id: sensor.pixel_7_battery_level
domain: sensor
above: 84
condition:
- condition: zone
entity_id: device_tracker.pixel_7
zone: zone.home
- condition: state
entity_id: sensor.pixel_7_battery_state
state: charging
action:
- if:
- condition: time
after: "06:00:00"
before: "23:33:00"
weekday:
- sat
- fri
- thu
- wed
- tue
- mon
- sun
then:
- service: light.turn_on
data:
rgbw_color: green
target:
entity_id: light.lamp
- service: switch.turn_off
data: {}
target:
entity_id: switch.usb_switch
mode: single
3.NFC tag to trigger automation
Here i will share only the general idea so you can be inventive and apply it on your situation.
In the living room we usually meditate (me and my girlfriend) or read and sometimes if we are not moving for a while the lights shut off.
So i created an automation that disables the Light turn off automation, sets the lights at a certain brightness.
alias: Tag - Meditație living
description: ""
trigger:
- platform: tag
tag_id: 8b7cdfde-3eb0-49d6-9058-aafd367a000d
condition: []
action:
- service: automation.toggle
data: {}
target:
entity_id:
- automation.living_lumina_on_miscare_detectata
- automation.living_fara_miscare_lumini_off
- service: light.turn_off
data: {}
target:
entity_id:
- light.living_bed_lamp
- light.living_lamp
- light.living_window_lamp
- light.podcast
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: light.toggle
data:
brightness_pct: 15
target:
entity_id: light.podcast
mode: single
4.Turn on the light next to the fridge when you open the door
I dont know about you but the light inside of my fridge is very dimm and i usually have to turn on the bulb that is placed just in front of my fridge.
This is functional enough but it get a little bit difficult when you have something in your hand and the hallway is dark and you need to turn on the light.
Next to my fridge i have installed a smart bulb and on the door ive placed a door sensor.
When i open the fridge door the light turns on and after a few seconds after i close the door it turns off.
alias: Hol - Ușa fridge deschisă bec aprins
description: ""
trigger:
- type: opened
platform: device
device_id: a814ffacb9808e54158efccd13f9f20b
entity_id: binary_sensor.fridge_door_sensor_contact
domain: binary_sensor
condition: []
action:
- service: light.turn_on
data: {}
target:
entity_id: light.0x00178801043858eb
mode: restart
5.Turn on my speakers after the computer is on
I have a really cheap 2.1 System.
Its perfectly fine for what i need but then its not playing anything on it makes a static noise that is not that pleasant, especially at night when you are trying to sleep.
So ive activated Wake on Lan on my computer in order to see its status on the network, then ive placed a smart plug for the speakers so i can turn them on and off remotely.
When the computer is on, the speakers turn on, when the computer is off the speakers turn off.
alias: Cameră - boxă on
description: ""
trigger:
- platform: state
entity_id:
- switch.nuc
from: "off"
to: "on"
condition: []
action:
- service: switch.turn_on
data: {}
target:
entity_id: switch.speaker_switch_speaker_relay
mode: single
What cool/useful automation ideas for Home Assistant do you have? Please share them below.