Customizing the icon of an entity
Emiliano Guerzoni
Project Manager | BESS Development | Driving 3+ GW of Energy Storage Projects in Italy
Welcome to another exciting tutorial of my?Tips & Tricks?newsletter on?Home Assistant!
Did you know that home automation can help you in reducing by over 10% the energy bill each year?
As a home automation enthusiast, I'm always on the lookout for new ways to make my life easier as well as smarter and I'm excited to share my latest ideas with you.
So, if you're ready to take your home automation game to the next level, read on and don't forget to let me know your thoughts in the comments.
Your feedback will help me ensure that I'm providing the right content for you.
Thanks for being a valued reader! ??
In the last episode I introduced the Zigbee world and how to create a Zigbee network in Home Assistant.
To test the Zigbee network I also bought the Aqara Door & Window?and the Aqara Temperature & Humidity?Zigbee sensors.
The Aqara Door & Window sensor is identified as lumi.sensor_magnet.aq2 and it introduces the entity: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening to be used to get the status (open / closed) of the element on which the sensor is installed on.
By default this entity is shown as Opening so that the assigned icon is the one reported below:
Continuing reading you'll get how to change the icon of the entity sensor accordingly.
Hardware configuration
Software configuration
Procedure
There are some different ways to customize the icon of the entity sensor.
Go to Settings->Devices & Services and open the devices reported by the Zigbee integration:
领英推荐
Now select the device for which you want to change the icon:
and select the entity binary_sensor.lumi_lumi_sensor_magnet_aq2_opening:
Change the Show as field from Opening to Window:
The icon will be set to the mdi:window-open / mdi:window-closed according to the state of the entity (ON / OFF).
This is a simple way to change the icon but it doesn't allow you to have full control on the entity's icon.
2. The second way is a more powerful procedure and needs to get back to the yaml code to create the following template sensor:
- binary_sensor:
? ?- name: Bedroom window
? ? ?unique_id: bedroom_window
? ? ?device_class: window
? ? ?state: >
? ? ? ? {% if is_state("binary_sensor.lumi_lumi_sensor_magnet_aq2_opening", "off") %}
? ? ? ? ? off
? ? ? ? {% elif is_state("binary_sensor.lumi_lumi_sensor_magnet_aq2_opening", "on") %}
? ? ? ? ? on
? ? ? ? {% endif %}
? ? ?icon: >
? ? ? ? {% if is_state("binary_sensor.lumi_lumi_sensor_magnet_aq2_opening", "off") %}
? ? ? ? ? mdi:window-closed-variant
? ? ? ? {% elif is_state("binary_sensor.lumi_lumi_sensor_magnet_aq2_opening", "on") %}
? ? ? ? ? mdi:window-open-variant
? ? ? ? {% endif %}
As you can see the icon section allows you to get the right icon you really want according to the entity's state.
In this specific case the entity to be reported on the Home Assistant GUI will be the: binary_sensor.bedroom_window.
Below the final result you get using the procedures described above:
I do hope that the tips and tricks provided by this new tutorial have been helpful in getting you started with home automation or improve your general skills.
As always, if you have any questions or feedback, please don't hesitate to reach out and let me know. Your input is greatly appreciated and will help me to continue providing high-quality content that meets your needs.
Meanwhile,?if you liked this article share it and don't forget to?subscribe?to my newsletter about?Home Assistant, you will be the first to know about my new articles!
I look forward to sharing more?Home Assistant?insights with you in the future!