Replies: 2 comments 1 reply
-
That matches my recollection, yes - that Z2M's fan model supports only a small finite set of speeds, not an arbitrary numeric range. Also worth noting that (as I recall, from a couple years ago...) Home Assistant's fan model treats speed-based control as mutually exclusive to mode-based control, and intends that any fan "control" that can be used in parallel with a speed control be modeled as a different HA entity, rather than as a fan "mode". In other words, when HA sets a speed, it expects the mode to be cleared, and vice versa. I think you'd need to do the necessary Z2M fan model changes to support a numeric speed OR a finite set of speeds, and then from there differentiate the entire generated HA MQTT discovery payload based on model of fan, in order to support the 255-level control you've got on your custom device. A more disruptive/breaking-change level alternative could changing the fan model and MQTT layer to an arbitrary numeric for all Z2M fans, and then implement something like the FWIW I think this question may be germane to the Inovelli zigbee fans as well, e.g. VZM36? The ZHC converter appears to be pre-selecting some low/medium/high buckets for the fan speed today, and might also benefit from directly forwarding the raw 255-level control to the smart home coordinator: https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/inovelli.ts#L1782-L1796 |
Beta Was this translation helpful? Give feedback.
-
Koenkk/zigbee-herdsman-converters#8188 Initial implementation, I havent' touched the Inovelli fans as I don't have any to test. |
Beta Was this translation helpful? Give feedback.
-
I made a custom Zigbee fan device. As it has fairly fine control (which higher-level control systems do use) and no reasonable auto mode I implemented it as a level-controlled device (having a onOff and a levelCtrl cluster). But trying to write a converter for an MQTT Fan seems impossible without touching a significant chunk of code outside of the converter itself as the HA discovery and device model in Z2M do not support numeric speeds. I hacked together a converter based on a light, which works well but is obviously a hack.
I looked at the HA MQTT Fan spec and it looks like setting something like speed_range_min: 1 speed_range_max: 255 and no presets should result in a value from 1 to 255 arriving via percentage_command_topic, which can then be forwarded directly to the levelCtrl cluster on the Zigbee side. This would also make it convenient for other automation on the MQTT bus to use.
I need to touch at least https://github.com/Koenkk/zigbee-herdsman-converters/blob/a554f6be1e461e19d03c7bf61f748cfcc10ff86b/src/lib/exposes.ts#L557 and https://github.com/Koenkk/zigbee2mqtt/blame/e06848db8c5ad247c27e959eb85465a30134769f/lib/extension/homeassistant.ts#L932.
Basically before I spend a lot of time on this I'd appreciate some input on how this should be done and how we can support both level-controlled fans as well as classical mode-based fans.
Tagging @Koenkk as you own the project and @cmccambridge as you last made significant modifications to the infrastructure I need to touch. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions