Thanks. But been too busy outdoors to try this. Maybe this weekend !
Using your new code but revised for my fan and switch nomenclature, can turn fan on and change speed. However, cannot turn fan off. Thought it might be because I left out the automation: section of your fan_package.yaml. But when included, still cannot turn fan off. Apologises, but I am an extreme novice with yaml - I just copy and modify others code !
Just to clarify…
you are using the fan percent button row (not the fan control entity row) plugin?
and have you updated to the latest version?
there was an issue that I made a change for recently so if not on the latest try that first to see if it’s resolved.
Definitely using fan-percent-button-row 1.3. (I did reload as on my PC the timestamp was different). Also by using call service I have checked that the coding of my Broadlink turn off switches still work - they do.
But still off not working. As before have tried both with and without your automation: section but makes no difference, i.e. still not working.
fan:
- platform: template
fans:
landing_fan:
friendly_name: "Landing Fan"
value_template: "{{ states('input_boolean.landing_fan_state_percent') }}"
percentage_template: "{{ states('input_number.landing_fan_speed_percent') | float }}"
turn_on:
service: script.landing_fan_on_percent
turn_off:
service: script.landing_fan_off_percent
set_percentage:
service: script.landing_fan_set_speed_percent
data:
percentage: "{{ percentage }}"
speed_count: 3
input_number:
landing_fan_speed_percent:
name: Landing Fan Speed Percent
min: 0
max: 100
step: 1
input_boolean:
landing_fan_state_percent:
name: Landing Fan State Using Percents
script:
landing_fan_off_percent:
alias: Landing Fan Off
sequence:
- service: switch.turn_on
entity_id: switch.off_lf
- service: input_boolean.turn_off
data:
entity_id: input_boolean.landing_fan_state_percent
landing_fan_on_percent:
alias: Landing Fan On
sequence:
- service: input_boolean.turn_on
entity_id: input_boolean.landing_fan_state_percent
- service: script.landing_fan_set_speed_percent
landing_fan_set_speed_percent:
alias: Landing Fan Set Percentage
sequence:
- service: input_number.set_value
entity_id: input_number.landing_fan_speed_percent
data:
value: "{{ percentage }}"
- delay:
milliseconds: 500
- service: >
{% if states("input_number.landing_fan_speed_percent") | int == 33 %}
script.landing_fan_low
{% elif states("input_number.landing_fan_speed_percent") | int == 66 %}
script.landing_fan_med
{% elif states("input_number.landing_fan_speed_percent") | int == 100 %}
script.landing_fan_high
{% else %}
script.landing_fan_off_percent
{% endif %}
- service: >
{% if states("input_number.landing_fan_speed_percent") | int == 33 %}
input_boolean.turn_on
{% elif states("input_number.landing_fan_speed_percent") | int == 66 %}
input_boolean.turn_on
{% elif states("input_number.landing_fan_speed_percent") | int == 100 %}
input_boolean.turn_on
{% else %}
input_boolean.turn_off
{% endif %}
entity_id: input_boolean.landing_fan_state_percent
landing_fan_low:
alias: Landing Fan Low
sequence:
- service: switch.turn_on
entity_id: switch.low_lf
landing_fan_med:
alias: Landing Fan Medium
sequence:
- service: switch.turn_on
entity_id: switch.medium_lf
landing_fan_high:
alias: Landing Fan High
sequence:
- service: switch.turn_on
entity_id: switch.high_lf
Honestly I’m not sure why it isn’t working. It works using my own fan here.
At this point the only thing I know to try is to:
first, try removing the fan-percent-button-row.js file completely. restart HA. Clear your cache (ctrl-F5 in chrome browser) and re-install the fan-percent-button-row.js file.
next if that doesn’t work then you can look at the updated fan percent package that I just uploaded to github: Home-Assistant/fan_package_percents_broadlink.yaml at 7d20332015e3b903e1c7c5221b8700fd4b8ff07f · finity69x2/Home-Assistant · GitHub
and check that file to see where your config might be different (aside from all the entities obviously).
Let me know if it works and if not we can go from there but I’m not sure what to do next if all of that fails.
For anyone who wants the old speed list functionality reinstated.
I’ve requested that the old speed list options should be kept and I’ve had a suggestion from a dev that if a FR gets enough votes they would implement it.
Here is the FR. Please go there and vote it up.
Finally got all the 3 fans I have to turn off. My problem maybe was because of the way I have the Broadlink commands set up, i.e using command_on and command_off switches. Therefore instead of :
landing_fan_off_percent:
alias: Landing Fan Off
sequence:
- service: **switch.turn_on**
entity_id: switch.off_lf
what works for me is:
landing_fan_off_percent:
alias: Landing Fan Off
sequence:
- service: **switch.turn_off**
entity_id: switch.off_lf
I wasn’t entirely sure where to post this, but decided rather than revive a 2 year old thread I’ll post here as it’s still more active. I have a challenge trying to adapt the code from Help with a template sensor that sets a number based on values between two numbers and integrate this information into the fan component.
My fans have lights built-in, running off the same DC driver with RF control. In my existing setup, the states are simply set by the last RF command sent, which for various reasons often ends up out-of-sync.
I couldn’t find a suitable replacement DC controller therefore am testing out the use of a Shelly 1PM on the AC supply side of the DC controller to monitor energy consumption and feed this information back into HA.
So I needed to take a set of combined energy consumption values and get HA to validate the state of both the fan and the light. Below are the stable values I observed in the power monitoring:
Fan & light both off: 0.8 - 1.0w
Fan 1 & light off: 5.3 - 5.4w
Fan 2 & light off: 9.5 - 10.2w
Fan 3 & light off: 15.5 - 16.1w
Fan 4 & light off: 22.3 - 23.0w
Fan 5 & light off: 36.8 - 37.1w
Fan off & light on: 21.2 - 21.6w
Fan 1 & light on: 25.7 - 25.9w
Fan 2 & light on: 30.2 - 30.7w
Fan 3 & light on: 36.4 - 36.5w
Fan 4 & light on: 42.9 - 43.3w
Fan 5 & light on: 55.0 - 57.5w
And here is how I’ve attempted to utilise the code from the other thread, to build sensors to accomplish the first stage:
dining_fan_power:
friendly_name: "Dining Fan Power"
device_class: power
value_template: >-
{% set fan_power = states('sensor.shelly_1pm_dining_room_power') | float %}
{% if 0 < fan_power <= 2 %}
Off
{% elif 21 <= fan_power <= 22 %}
Off
{% elif 5 <= fan_power <= 8.9 %}
1
{% elif 25 <= fan_power <= 29.9 %}
1
{% elif 9 <= fan_power <= 14.9 %}
2
{% elif 30 <= fan_power <= 35.9 %}
2
{% elif 15 <= fan_power <= 20.9 %}
3
{% elif 36 <= fan_power <= 36.8 %}
3
{% elif 22.1 <= fan_power <= 24.9 %}
4
{% elif 42 <= fan_power <= 54.9 %}
4
{% elif 36.9 <= fan_power <= 41.9 %}
5
{% elif 55 <= fan_power <= 60 %}
5
{% endif %}
dining_light_power:
friendly_name: "Dining Light Power"
device_class: power
value_template: >-
{% set light_power = states('sensor.shelly_1pm_dining_room_power') | float %}
{% if 0 < light_power <= 2 %}
Off
{% elif 5 <= light_power <= 8.9 %}
Off
{% elif 9 <= light_power <= 14.9 %}
Off
{% elif 15 <= light_power <= 20.9 %}
Off
{% elif 22.1 <= light_power <= 24.9 %}
Off
{% elif 36.9 <= light_power <= 41.9 %}
Off
{% elif 21 <= light_power <= 22 %}
On
{% elif 25 <= light_power <= 29.9 %}
On
{% elif 30 <= light_power <= 35.9 %}
On
{% elif 36 <= light_power <= 36.8 %}
On
{% elif 42 <= light_power <= 54.9 %}
On
{% elif 55 <= light_power <= 60 %}
On
{% endif %}
It’s a bit convoluted and messy, but it appears to do the job. Understandably the value isn’t stable immediately as there’s an initial surge in power use when stepping up, and there are potential issues where the energy usage is very similar between the fan on speed 3 with the light on, and the fan on speed 5 with the light off - so I don’t want this information to be solely relied upon in real-time by HA for defining the state, but what I would like to do is have HA cross-reference the state against this information periodically, to identify any sync issues.
Here is a screencapture of the front end demonstrating the sensor information being displayed:
This is the code I’m using for my fan components:
fans.yaml
- platform: template
fans:
dining_fan:
friendly_name: "Dining Fan"
value_template: "{{ states('input_boolean.dining_fan_state') }}"
speed_template: "{{ states('input_select.dining_fan_speed') }}"
turn_on:
service: script.dining_fan_on
turn_off:
service: script.dining_fan_off
set_speed:
service: script.dining_fan_set_speed
data_template:
speed: "{{ speed }}"
speeds:
- "lowest"
- "low"
- "medium"
- "high"
- "highest"
input_booleans.yaml
dining_fan_state:
name: Dining Fan State
input_selects.yaml
dining_fan_speed:
name: Dining Fan Speeds
options:
- 'off'
- 'lowest'
- 'low'
- 'medium'
- 'high'
- 'highest'
scripts.yaml
dining_fan_off:
alias: Dining Fan Off
sequence:
- service: switch.turn_on
entity_id: switch.dining_fan_off
- service: input_boolean.turn_off
data:
entity_id: input_boolean.dining_fan_state
dining_fan_on:
alias: Dining Fan On
sequence:
- service: input_boolean.turn_on
data:
entity_id: input_boolean.dining_fan_state
- service_template: >
{% if is_state("input_select.dining_fan_speed", "lowest") %}
script.dining_fan_lowest
{% elif is_state("input_select.dining_fan_speed", "low") %}
script.dining_fan_low
{% elif is_state("input_select.dining_fan_speed", "medium") %}
script.dining_fan_medium
{% elif is_state("input_select.dining_fan_speed", "high") %}
script.dining_fan_high
{% elif is_state("input_select.dining_fan_speed", "highest") %}
script.dining_fan_highest
{% endif %}
dining_fan_set_speed:
alias: Dining Fan Set Speed
sequence:
- service: input_select.select_option
data_template:
entity_id: input_select.dining_fan_speed
option: "{{ speed }}"
- delay:
milliseconds: 500
- service: script.turn_on
entity_id: script.dining_fan_on
dining_fan_lowest:
alias: Dining Fan Lowest
sequence:
- service: switch.turn_on
entity_id: switch.dining_fan_lowest
dining_fan_low:
alias: Dining Fan Low
sequence:
- service: switch.turn_on
entity_id: switch.dining_fan_low
dining_fan_medium:
alias: Dining Fan Medium
sequence:
- service: switch.turn_on
entity_id: switch.dining_fan_medium
dining_fan_high:
alias: Dining Fan High
sequence:
- service: switch.turn_on
entity_id: switch.dining_fan_high
dining_fan_highest:
alias: Dining Fan Highest
sequence:
- service: switch.turn_on
entity_id: switch.dining_fan_highest
switches.yaml
- name: dining_fan_off
command_on: '[code redacted for brevity]'
command_off: '[code redacted for brevity]'
- name: dining_fan_lowest
command_on: '[code redacted for brevity]'
command_off: '[code redacted for brevity]'
- name: dining_fan_low
command_on: '[code redacted for brevity]'
command_off: '[code redacted for brevity]'
- name: dining_fan_medium
command_on: '[code redacted for brevity]'
command_off: '[code redacted for brevity]'
- name: dining_fan_high
command_on: '[code redacted for brevity]'
command_off: '[code redacted for brevity]'
- name: dining_fan_highest
command_on: '[code redacted for brevity]'
command_off: '[code redacted for brevity]'
And for the lights…
lights.yaml
- platform: switch
name: Dining Room
entity_id: switch.dining_room_light
switches.yaml
- name: dining_room_light
command_on: '[code redacted for brevity]'
command_off: '[code redacted for brevity]'
Would anybody be able to suggest how I could go about making HA use the energy consumption information to ensure the state is maintained correctly?
Thank you
@finity - Great job on this custom fan card! I was wondering whether there is some way for me to configure it to have 4 speeds instead of 3.
All my fan controllers are HomeSeer Technologies HS-FC200+ which can be set to 3 or 4 speeds. With 4 speeds you can set the fan to a speed where you can’t hear it as much but get more air flow so I would rather not set it to 3 speed.
Any suggesitons? Thanks!
Not with this card you can’t. it’s hard coded for a three speed fan.
But if you want to try one of my other fan controls the fan percent button row might work if you can get your fan speeds in percentages.
@finity I just tried your other card but I can’t figure out how to add the 4th speed setting. This is my attempt:
type: entities
title: Fans
show_header_toggle: false
entities:
- entity: fan.office_fan
type: custom:fan-percent-button-row
name: Office Fan
customSetpoints: true
lowPercentage: 24
medPercentage: 49
highPercentage: 74
maxPercentage: 100
customHiText: High
customLowText: Low
customMedText: Med
customMaxText: Max
customOffText: 'Off'
width: 25px
height: 25px
But I still get:
You can’t add a 4th speed. it’s only a three speed control row. but you can set the different settings for the three speeds available in the control row to whatever percents you want.
lowPercentage: 24
medPercentage: 49
highPercentage: 100
or
lowPercentage: 49
medPercentage: 74
highPercentage: 100
or…
Ah, ok. I guess I could skip the lowest setting as it is typically too slow anyway. The two most valuable speeds with the smaller fans < 58 inch are 49 and 74, while for the fans > 58 inch are 24, 49 and 74 as 100 gets noisy and quite… windy!
Thanks!
Those control rows were written as a more convenient way to access the speeds of the fans without needing to open the fan entity and use the more-info card to select the speeds.
When the other cards were added I made those to be able to quickly set a few selectable fan percentages/light brightness settings directly without needing the more info pop up.
But users can still bring up the more info card to fine tune or select other settings just like always.
Again, it was meant to be more of a convenient minimum setpoint selection than a full featured control row.
Which is also why I’ve been hesitant to add more than 4 total buttons. There just isn’t that much room in a column.
Is it possible with this card to hide the Name and/or Icon?
No, not possible. Sorry.
I have this card working nicely with a fan controlled by Tasmota which has the MQTT config setup to provide the old descriptive speed modes, but a newer fan controller I built which runs ESPhome doesn’t seem to want to work with this card. Wondering if someone can help me out here.
entity: fan.games_room_fan
attributes of fan:
speed_list: off, low, medium, high
preset_modes:
speed: high
percentage: 100
percentage_step: 33.333333333333336
preset_mode: null
friendly_name: Games Room Fan
supported_features: 1
Card config:
type: entities
entities:
- type: custom:fan-mode-button-row
entity: fan.games_room_fan
lowPercentage: 33
medPercentage: 66
highPercentage: 100
The above image is showing the fan is OFF, but it is actually on HIGH as shown in the attributes listed above. Trying to use the card doesn’t work at all to change the fan speed.
Any tips?
try using the "fan-percent-button-row’ instead.
the mode plugin only works with predefined modes not percentages.
Awesome! Thanks for this, I didn’t know it existed.
I am hoping someone can help get this card working properly. My fan setup is for a 303MHz Hampton Bay ceiling fan and I am running it with OpenMQTTGateway through a Wemos D1 Mini attached to a CC1101 transceiver. Everything in this regard works but I just can’t get this custom card to work. The issue I am having is when I push the buttons everything does what it is supposed to do (except for the OFF, button but I can save that for another time) controlling the fan but the buttons don’tt change color to show what button is active. Any help would be greatly appreciated, thank you!
YAML
fan:
- platform: mqtt
name: Samuel Fan
availability_topic: "home/OpenMQTTGateway/LWT"
state_topic: "home/OpenMQTTGateway/433toMQTT/Samuel_Fan/state"
command_topic: "home/OpenMQTTGateway/commands/MQTTto433"
state_value_template: "{{ value_json.value }}"
payload_on: '{"value":16774298,"protocol":11,"length":24,"delay":386, "repeat": 5}'
payload_off: '{"value":16774299,"protocol":11,"length":24,"delay":386, "repeat": 5}'
qos: "0"
retain: true
preset_modes:
- "off"
- "high"
- "medium"
- "low"
preset_mode_command_topic: "home/OpenMQTTGateway/commands/MQTTto433"
preset_mode_command_template: >
{% if value == 'high' %}
{"value":16774145,"protocol":11,"length":24,"delay":386, "repeat": 5}
{% elif value == 'medium' %}
{"value":16774146,"protocol":11,"length":24,"delay":386, "repeat": 5}
{% elif value == 'low' %}
{"value":16774147,"protocol":11,"length":24,"delay":386, "repeat": 5}
{% else %}
{"value":16774144,"protocol":11,"length":24,"delay":386, "repeat": 5}
{% endif %}
preset_mode_state_topic: "home/OpenMQTTGateway/433toMQTT/Samuel_Fan/speed"
preset_mode_value_template: "{{ value_json.value }}"
Custom Card
entity: fan.samuel_fan
type: custom:fan-mode-button-row
name: Fan Custom Button Text
customTheme: true
twoModeFan: false
width: 50px
height: 50px
isOnModeOneColor: red
isOnModeTwoColor: green
buttonInactiveColor: orange
customText: true