Make the speed display entries configurable, take the speed entries from speed_list
Closed this issue · 5 comments
I tried to set up a fan and integrated it to lovelace with your control. I assume my setup is somehow wrong:
- Installed it via HACS, current version is 1.5
- Configured fan via fan template, it works through developer tools, I tried
fan.turn_on
,fan.turn_off
,fan.toggle
andfan.set_speed
- In developer tools the fan state reports
speed_list:
- '1'
- '2'
- '3'
speed: '1'
friendly_name: Wohnraumlüftung
supported_features: 1
The fan template looks like:
fan:
- platform: template
fans:
ventilation_fan:
friendly_name: "Wohnraumlüftung"
value_template: >-
{% if states('switch.switch_ventilation_relay_1') == 'on' %}
off
{% else %}
on
{% endif %}
speed_template: >-
{% if states('switch.switch_ventilation_relay_2') == 'on' %}
2
{% elif states('switch.switch_ventilation_relay_3') == 'on' %}
3
{% else %}
1
{% endif %}
turn_on:
service: switch.turn_off
data:
entity_id: switch.switch_ventilation_relay_1
turn_off:
service: switch.turn_on
data:
entity_id: switch.switch_ventilation_relay_1
set_speed:
service_template: >-
{% if speed == '1' %}
script.ventilation_fan_1
{% elif speed == '2' %}
script.ventilation_fan_2
{% elif speed == '3' %}
script.ventilation_fan_3
{% endif %}
speeds:
- '1'
- '2'
- '3'
I integrated it in lovelace with
- type: entities
title: Belüftung
show_header_toggle: false
entities:
- entity: fan.ventilation_fan
type: custom:fan-control-entity-row
name: Wohnraumlüftung
but the buttons are not initialized correctly and are not selectable - the state was
speed_list: 1, 2, 3
speed: 1
friendly_name: Wohnraumlüftung
supported_features: 1
and state on
, so "LOW" should have been selected.
My home assistant version is
arch | armv7l |
---|---|
chassis | embedded |
dev | false |
docker | true |
hassio | true |
host_os | HassOS 4.8 |
installation_type | Home Assistant |
os_name | Linux |
os_version | 5.4.42-v7l |
python_version | 3.7.7 |
supervisor | 226 |
timezone | Europe/Vienna |
version | 0.110.4 |
virtualenv | false |
The theme is https://github.com/JuanMTech/google_dark_theme
Changes are high that I did something wrong, would be glad if you could point me in the right direction.
Found a log entry:
Received invalid speed: low. Expected: ['1', '2', '3'].
21:03:46 – template (ERROR) - Die Nachricht ist zum ersten Mal um 19:35:17 aufgetreten und erscheint 5 mal
Works now, had to use your values:
fan:
- platform: template
fans:
ventilation_fan:
friendly_name: "Wohnraumlüftung"
value_template: >-
{% if states('switch.switch_ventilation_relay_1') == 'on' %}
off
{% else %}
on
{% endif %}
speed_template: >-
{% if states('switch.switch_ventilation_relay_2') == 'on' %}
medium
{% elif states('switch.switch_ventilation_relay_3') == 'on' %}
high
{% else %}
low
{% endif %}
turn_on:
service: switch.turn_off
data:
entity_id: switch.switch_ventilation_relay_1
turn_off:
service: switch.turn_on
data:
entity_id: switch.switch_ventilation_relay_1
set_speed:
service_template: >-
{% if speed == 'low' %}
script.ventilation_fan_1
{% elif speed == 'medium' %}
script.ventilation_fan_2
{% elif speed == 'high' %}
script.ventilation_fan_3
{% endif %}
speeds:
- 'low'
- 'medium'
- 'high'
Expected that your control takes the allowed values from speed_list
;
speed_list: low, medium, high
speed: low
friendly_name: Wohnraumlüftung
supported_features: 1
But then you also have to provide an attribute for the display values like
speed_display_list: LOW, MED, HIGH
Since I do not live in an English speaking country, I would prefer 1, 2, 3 - so I changed the title of this issue to ask for adaptable values.
BTW, the fan icon doesn't change it's color - not sure if this is an error of mine.
I can add a configurable text to the different speed/state buttons. Others have asked for that too but I didn't know how to accomplish it until the inspiration struck me last night after thinking about it for a bit. It turns out it was way easier than I thought and it only took an hour or so of trial and error to get it all worked out.
But I don't think I can figure out how to draw in the speeds from the list so I likely won't change that.
So you got part of what you wanted :)
Give me a day or so to get the changes uploaded. I'm working on the other issue here first and only want to make one change instead of making two changes in a row right away.
added custom button text