finity69x2 / fan-percent-button-row

Frontend plugin to control fans in Home Assistant using percent values for speeds
32 stars 19 forks source link

Medium speed not being highlighted when medPercentage is 50 #19

Closed heschlie closed 2 years ago

heschlie commented 2 years ago

First, my config:

type: entities
entities:
  - entity: fan.office_ceiling_fan_2
    type: custom:fan-percent-button-row
    customTheme: false
    lowPercentage: 25
    medPercentage: 50
    hiPercentage: 100
    reverseButtons: true

So, everything actually works, when I click any of the buttons the fan changes to the corresponding speed, but when I click MED the fan speed changes but the button isn't highlighted. If I click any of the others the corresponding button is highlighted. If I change medPercentage to 51, it seems to start working, so I'm wondering if what is being reported back by HA might not be exactly what this is watching for or something?

finity69x2 commented 2 years ago

I'm not sure why changing the speed setpoints in the config makes any difference because you are telling the button row to actually use the custom setpoints. there is an option ('customSetpoints') that needs to be set to true in order to use your own setpoints otherwise it uses 33, 66, 100 percent as the default setpoints.

but can you look at the fan speed when you set it to medium with the setpoint set to 50 and see what the actual fan percent setting is in the dev tools states page? it should be in an attribute somewhere.

heschlie commented 2 years ago

Interesting, so this may be a different bug then. I verified that when the buttons are clicked they are setting the fan to those percentages (25,50,100) by watching the entity. I set the customSetpoints option after, and the buttons now also work as expected.

I didn't take time to get familiar with the codebase (sorry!) but perhaps this is the culprit? It looks like if you set those values with or without the customSetpoints they are set to whatever is in the yaml?

finity69x2 commented 2 years ago

I updated the code to ignore the custom setpoint values if the "customSetpoints" option was not set to "true".

try it out once it gets updated in HACS and see if that fixes it for you.

Thanks for catching that.