Open slim0287 opened 3 years ago
The logic should be inspired by https://github.com/home-assistant/core/blob/dev/homeassistant/components/fan/__init__.py
This can be a bit tricky to get fully correct.
This would be helpful for me as well. My Enbrighten ZWave Fan switch uses percentage, which the TYPES.FAN didn't handle. I put together a very clunky slider with min=0, max=100, and step=33, but it is not very consistent. I use the step=33 to simulate the low, med, high settings.
I'm starting to look at TileBoard for my wall-mounted tablets, but not having fan speed control is pretty-much a non-starter since I have ceiling fans in nearly every room. @rchl have you had any more thoughts on how to set this up? I'm willing to take a dive into the code, but javascript isn't something I write all that often.
At the most basic level it looks like it's replacing this line in scripts/controllers/main.js:
callService(item, 'fan', 'set_speed', { speed: option });
with a call to the set_percentage service. But it is going to need some logic around how those percentages get set, for example polling the percentage_step from the fan device and defining how to map speeds to percentages... That probably also implies creating fan speed up and down methods as well that would just increase the percentage by percentage_step. And then everyone (myself included) is going to want to be able to define a hash to map speed percentages to the display value.
What I find really odd in the HA implementation is that percentage_step doesn't map to reality. For example if I set my office fan on low, it shows 25% for the percentage on the device. 74% is medium, and 100% is high. That doesn't match the percentage_step value of 33.333%. | Entity | State | Attributes |
---|---|---|---|
fan.office_fanOffice Fan | on | preset_modes: null percentage: 25 percentage_step: 33.333333333333336 preset_mode: null friendly_name: Office Fan supported_features: 1 |
|
-- | -- | -- |
Sorry but I can't help much here. I don't really have time to maintain this code and even if I would, I don't have any devices to test with.
If someone provides a pull request then it would most likely be merged (though most likely without thorough review due to no devices to test with).
The TYPES.FAN tile speed control approach in TileBoard/scripts/directives/tile.html uses the fan entity attributes
speed
andspeed_list
, both of which are deprecated and replaced withpercentage
,preset_mode
, andpreset_modes
. This is documented in the Home Assistant developer docs on the fan entity: https://developers.home-assistant.io/docs/core/entity/fan/For fans with more than three speeds, the deprecated attributes are left blank and then the TileBoard fan tile does not show any speed control. I suggest the TYPES.FAN code be updated to use the new fan entity attributes.