Closed jbouwh closed 3 years ago
In addition to address this as an issue. Using the mqtt fan integration using set_speed
(the only available method now) results to warnings in the logging:
Logger: homeassistant.components.fan
Source: components/fan/__init__.py:231
Integration: Fan (documentation, issues)
First occurred: 7:30:00 (1 occurrences)
Last logged: 7:30:00
fan.set_speed is deprecated, use fan.set_percentage or fan.set_preset_mode instead.
Transferring the issue into a discussion.
Context
This as a follow up on architecture discussion https://github.com/home-assistant/architecture/issues/127. The fan core identity fas been changed recently to support speed percentage. Using speeds (off, low, medium and high) is decrepated now. Since HA core-2021.3.2 the fan integration has been updated. Separate fan speeds into percentages and presets modes #45407 The mqtt.fan should follow this architecture update.
Proposal
Update the mqtt fan integration to support setting a speed percentage.
Consequences
This will enable to pass percentage based speeds to MQTT fans and te be conformant to the architecture changes of the
fan
integration and core identity updates.The current 'speeds' attribute will remain working as it is now to support backwards compatiblity. Functions to translate between predefined speeds and percentages have been built into ha core already (
speed_to_percentage()
andpercentage_to_speed()
incomponents/fan
)If both
speeds
andpercentage
methods are advertised (or set through config) the predefined functions will be used to translate a percentage to predefined speed and back (speed_to_percentage()
andpercentage_to_speed()
incomponents/fan
).A MQTT fan advertises a
percentage_command_topic
to ha core mqtt auto discovery it supports percentage based variable speeds. Apercentage_state_topic
is used to report back the actual percentage set by the fan. Apercentage_value_template
defines te template to extract the percentage from the payload.