kommis
(Kommis)
December 12, 2021, 10:04am
1
Hello,
I hope you can help me. I want to change the text of the state from on/off to open/close.
I have this code in the configuration.yaml:
platform:
template sensors:
Garage open/close:
friendly_name: Garage open/close
entity_id: binary_sensor.shelly1_bcddc277829e_external_input
value_template: > {% if is_state(‘binary_sensor.shelly1_bcddc277829e_external_input’, ‘on’) %}open {% else %}closed{% endif %}
Wenn i check the configuration the system writes a failure.
Can you help me to reach my result?
Thanks in advance,
Dominik
tom_l
December 12, 2021, 10:23am
2
Please format your pasted code so we can see what is wrong.
https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly
If you apply the garage_door
device class it will change the displayed state to open/closed (the actual state will still be on/off). The garage icon will change from open to closed with the state as well.
https://www.home-assistant.io/integrations/binary_sensor/#device-class
kommis
(Kommis)
December 12, 2021, 7:07pm
3
Hello! Thanks for your answer! I cannot change the device class. When I change the class, a few moments later the class is “Power”.
Thanks!!
Here is the formatted code:
- platform: template
sensors:
Garage:
friendly_name: Garage offen/geschlossen
entity_id: switch.shelly1_bcddc277829e
value_template:
{% if is_state('binary_sensor.shelly1_bcddc277829e_external_input', 'on') %}
Running
{% else %}
Stopped
{% endif %}```
kommis
(Kommis)
December 12, 2021, 7:11pm
4
Here is also a Screenshot of the binary sensor
tom_l
December 12, 2021, 9:30pm
5
This is confusing. Which entity are you trying to change the icon of, the switch or the binary sensor?
I think all you need to do is go to Configuration / Entities and find binary_sensor.shelly1_bcddc277829e_external_input
.
Click on it and change the “Show As” dropdown list selection.
kommis
(Kommis)
December 13, 2021, 6:20am
6
I want to change the binary sensor. Now it Shows only on/off. And I want the status open/close of my Garage door.
Thanks
tom_l
December 13, 2021, 6:41am
7
Go to Configuration / Integrations and select your Shelly device. Find the binary sensor on the device page and click on it. There should be a setting for “Show As”, set that then click the update button.
If there is not a a Show As option then put this in your configuration.yaml file:
homeassistant:
customize: !include customize.yaml
Create the file config/customize.yaml and put this in it:
binary_sensor.shelly1_bcddc277829e_external_input:
device_class: garage_door
1 Like
kommis
(Kommis)
December 13, 2021, 11:13am
8
Thanks for your help! Now it works fine!!!
tom_l
December 13, 2021, 11:34am
9
Did you do it though the UI or by using customize.yaml?
1 Like
kommis
(Kommis)
December 13, 2021, 4:39pm
10
Yes! Because the Show As option is not available
kommis
(Kommis)
December 13, 2021, 4:42pm
11
There are the settings of the binary sensor. Unfortunately no Show As option. But your code in the customize.yaml works fine.
kommis
(Kommis)
December 13, 2021, 4:45pm
12
But another question.
Is it possible to change the Icon depending on state?
Closed should be icon “mdi:garage-variant”
Open should be icon “mdi:garage-open-variant”
thanks!
tom_l
December 14, 2021, 12:32am
13
The device class should do that automatically. Are you not seeing this?
kommis
(Kommis)
December 14, 2021, 6:53pm
14
No, unfortunally the class take the same Symbol.
kommis
(Kommis)
December 14, 2021, 6:54pm
15
Now its closed. Here you can see the screenshot
tom_l
December 14, 2021, 9:45pm
16
Yeah I’ve just noticed my device classes aren’t applying icons correctly either. I’ll open an issue.
1 Like