HADashboard v2 Fan Mode

I have no problem adding for light switch or cameras as they are straight forward, however I’m struggling with Fan mode.

I have a ceiling fan which set it as Speed 3, Speed 2, Speed 1, Off.
By breaking them individually into widget, it works. but the problem now is
e.g.
Execute Speed 3, (fan speed 3 activated) and icon lighted in green.
Execute Speed 2, (fan speed 2 activated) and icon lighted in green, but Fan speed 3 icon still lighted in green.

Is there anyway to group them or use if else command? so that after select 1 speed, the others speed icon will turn off.

Appreciated if you can screenshot of your example with config.

Thanks

you could create an input slect that choses 1 of your options or an input number that sets the number.
connect it to the fan with an automation and use that in the dashboard.

Noted… Thanks! Will work towards that approach. Will keep you updated!

1 Like

Hi ReneTode,

After working for days, finally got your recommendation setup completed. I can use them normally however surface 1 error which not sure which causing it.

from Input select.yaml:

livingfan:
  name: 'Living Fan:'
  options:
    - 'Speed 3'
    - 'Speed 2'
    - 'Speed 1'
    - 'Power Off'
  initial: 'Power Off'
  icon: mdi:fan

from automation.yaml:

- alias: Living Fan Commands
  trigger:
    - platform: state
      entity_id: input_select.livingfan
  action:
    - service: switch.turn_on
      data_template:
        entity_id: >
          {% if is_state("input_select.livingfan", "Speed 3") %}
            switch.living_fan_speed_3
          {% elif is_state("input_select.livingfan", "Speed 2") %}
            switch.living_fan_speed_2
          {% elif is_state("input_select.livingfan", "Speed 1") %}
            switch.living_fan_speed_1
          {% endif %}
          
- alias: Living Fan Off
  trigger:
    - platform: state
      entity_id: input_select.livingfan
  action:
    - service: switch.turn_off
      data_template:
        entity_id: >
          {% if is_state("input_select.livingfan", "Power Off") %}
            switch.living_fan
          {% endif %}

In HAdashboard.dash config:

livingfans3:
    widget_type: mode
    title: Living Fan Speed 3
    entity: input_select.livingfan
    icon_on: mdi-fan
    icon_off: mdi-fan
    mode: "Speed 3"
    post_service_active:
      service: input_select/select_option
      entity_id: input_select.livingfan
      option: "Speed 3"
    post_service_inactive:
      service: input_select/select_option
      entity_id: input_select.livingfan
      option: "Power Off"

livingfans2:
    widget_type: mode
    title: Living Fan Speed 2
    entity: input_select.livingfan
    icon_on: mdi-fan
    icon_off: mdi-fan
    mode: "Speed 2"
    post_service_active:
      service: input_select/select_option
      entity_id: input_select.livingfan
      option: "Speed 2"
    post_service_inactive:
      service: input_select/select_option
      entity_id: input_select.livingfan
      option: "Power Off"

livingfans1:
    widget_type: mode
    title: Living Fan Speed 1
    entity: input_select.livingfan
    icon_on: mdi-fan
    icon_off: mdi-fan
    mode: "Speed 1"
    post_service_active:
      service: input_select/select_option
      entity_id: input_select.livingfan
      option: "Speed 1"
    post_service_inactive:
      service: input_select/select_option
      entity_id: input_select.livingfan
      option: "Power Off"

After selecting any values from the input_select. This is the error I got from HA logs:

Invalid service data for switch.turn_off: Entity ID is an invalid entity id for dictionary value @ data[‘entity_id’]. Got ‘’

Service input_select/select_option called.

and

Invalid service data for switch.turn_on: Entity ID is an invalid entity id for dictionary value @ data[‘entity_id’]. Got ‘’

Service input_select/select_option called.

which appdaemon version do you use?

there is an error in the input_select.yaml that you have.
the service should be input_select/set_option.

Hi ReneTode,

Thanks for the response.

appdaemon version 2.1.12

in my hadashboard.dash config, I have changed input_select/select_option to input_select/set_option and got the following error:

“Unable to find service input_select/set_option”

hmm, i now just did read back your dashboard.
you are trying to do things with a widget that cant be done.

you need to add the custom widget input_select from my github


and then you have a select option, whith what you can select your fan mode when you chose widget type: input_select.

Could we request a custom fan-slider widget please? 1x1 widget with a slider to adjust fan speed.

PS. Muchos gracias for the light-slider, which has taken over my dashes. Much easier to control IMO.

i would love to help you with that, but i dont have a fan, so also no entity like that.
i would be very hard for me to program that.

but not impossible.

does your fan work with the climate widget?
because then i have a reference from where to work.

The fan component is different from climate (there is no temperature setting or display).

The services we need are fan.set_speed, fan.turn_on and fan.turn_off.

The complication is that speeds can vary from one fan platform to another. eg. Xiaomi air purifier (off, idle, auto, favorite) versus a normal ceiling fan (low, medium, high). So the slider will need logic to convert numerical slider value to one of the speeds (eg/ 0-33%= low, 34-66: medium and 66-100: high).

On second thoughts, maybe slider isn’t the easiest option. Fan speed is an input_select effectively (not numeric value) so maybe it makes sense to have a fan speed selector widget similar to MODE widget for set_speed and a fan switch widget for turn_on and off (the standard switch widget works fine so no work needed here). The difference from MODE would be that this single widget should be able to cycle through all options for the fan speed input select.

Can we use your input_select widget as a workaround in the meanwhile? How can it be used to point at fan.set_speed?

you can create an input_select with the right options.
then an automation that sets the fan speed when you change the input_select.
then you can use the input_select widget.

like you show it, its a combo from a switch and a input_select in HA also.
i dont think i have the option to read out the settings from the fan entity, so they would need to be set in the widget anyway.
the only real advantage that could be gained by making such a widget is that it puts 2 elements in 1 widget.
i already created a switch/slider widget, i could think about creating a switch/select combo

1 Like

Switch+input select would be perfect!

i will put it on my todo list, but i can take a while, because its not something i use and because its a very small advantage.
if it takes a while then please remind me at some point.

1 Like

Is it too soon to remind you already? :grin:

I’ll appeal to your trekkie side. The needs of the many outweigh the needs of the few.

PS. That LCARS skin looks bitching and I would totally use it if it weren’t for my SO. She’s not a Trekkie. I still have managed the transporter sound as my doorbell, though. Small victories.

1 Like

tell her that you can put way more information and button on a lcars dashboard.
create a sensor that gives her a sweet message every day and put that on the lcars skin.
find out what she likes and make that only work with lcars :wink:

there are always ways to win your partner over to your side. :stuck_out_tongue:

Got it working with a iFan03 tasmota, only problem I have is that the icon won’t spin or change colors.
fan_living:
widget_type: mode
widget_style: “border: 1px solid #696969; border-radius: 0pxfont-color: white; background: black; font-size: 126%”
entity: input_select.fan_living
title: Living
title_style: “color: white; font-size: 30px; font-weight: 400”
icon_on: mdi-fan mdi-spin
icon_off: mdi-fan
icon_style_inactive: “color:#1E90FF; font-size: 460%”
icon_style_active: “font-size: 460%; transition: 10s”
warn: 1
state_map:
“Off”: ‘OFF’
High: HIGH
Medium: MEDIUM
Low: LOW
state_text_style: “color: #fdd835; font-size: 20px; font-weight: 400”
state_text: 1
post_service_active:
service: input_select/select_next
entity_id: input_select.fan_living

it helps when you present yaml code as code.
only then its readable.

for icon_on you provide 2 icons. which wont work.
i dont see the option warn anywhere in the docs.
icon_style_active will only be used at the moment the widget is active.
the state that is given as active is set by using “mode”
https://appdaemon.readthedocs.io/en/latest/DASHBOARD_CREATION.html#mode

you use the mode widget to select a state from an input_select, but the only state shown is in the state text.
i think you are better off with the input_select widget.

“it helps when you present yaml code as code.
only then its readable.” The minute i learn how to do that i will, it will help if it was explained somewhere here for us basic computer users. I just don’t know how.

From the docs examples under " Detailed Widget Definition"

garage:
widget_type: switch
title: Garage
entity: switch.garage_door
icon_on: fas-car
icon_off: fas-car
warn: 1
Since the switch widget reference doesn’t list it I have no idea what it does.
“for icon_on you provide 2 icons. which wont work.” Actually it does work if i remove the last 3 lines of code, the icon will spin and change color. Obviously then the fan won’t receive the service call.

i dont know where they have put it now, but there has been a link to how on top of the forum, for ages.
when you type text on a browser, you have the place where you type text, at the top of that there are several options to change the text format, 1 of them is for code.
you can also use 3x on an empty line, before and after your code. (works here, in github, on discord and lots of other places.) and its and not ’ or "

you cant take options from 1 widget and use them in others. every widget has its own specific options. so if you find something in switch, then thats for switch only.

a widget recieves a service call when its supposed to. not setting the service call (which is nowhere documented) will make that the widget calls the service that it supposed to call :wink:

i didnt know that mdi used it that way, i thought it was used differently.

its obvious that it wont spin, because you change the value right after you have activated.
and you didnt set the mode.

you try to use a widget that is designed to activate a script to change an input_select
allthough it seems possible, you probably better use the input_select widget, because then you dont need the state part to show which state is activated.
and you got the option to turn it off when you are at low, without the need to go to medium and high.

I understand what you are saying about taking options from 1 to use in others or about the service call but i needed a solution and the input select won’t give me a fan icon for my fan
and I don’t mind going thru all the speed because that’s how I have on HA Lovelace.

You said that “its obvious that it wont spin, because you change the value right after you have activated.” do you know how to make it spin then? will be nice thought.

I have spend a lot of time trying to understand what’s on the docs and make things work with my limited knowledge. I know the docs don’t have examples for some of the widgets and some of the options have no explanation like “mode”, “warn” or “container_style” so I try and error until it works or i like it.:wink:

I really appreciated the work that you guys do.:100: