I am very new to home assistant, but have been playing around for a week.
I have an esp8266 controller that I have programmed to subscribe to an mqtt topic for command payloads and publish state responses to another topic.
The controller controls a two speed fan, so there’s three commands for off, low, and high speeds.
I’ve built a Lovelace tile that has buttons which publish mqtt payloads to the command topic and a sensor tile which changes its appearance based on the latest message to the state topic.
What would a fan device provide that isn’t accomplished by these mqtt buttons/sensor setup?
It’s just like with any other device, its just an entity class for knowing what controls it has available to it from the options already programmed on the HA side.
All that matters is that you are able to locally control, without relying on an internet connection should it go down, the target device be it with premade integrations that use them or DIY solutions if they don’t have them out of the box based on your needs and with as little headaches in the long term.
Not much. You’ve effectively duplicated a lot of the fan entity’s functionality manually. The entity just makes most of that automatic.
If you’re feeling bored some time, you can define a MQTT Fan entity that publishes to command topics and updates based on state topics. As you can see in the docs, it supports more features like oscillation, direction, and named presets that may not matter to you right now.
Personally I wrapped my underlying switches as fan entities because I bridge them all to Apple Home and now they appear as little fan icons inside the “climate” group, and when I tell Siri to set fan percentage it knows what I mean. Like so many things in HA, there is more than one way to do it, depending on your use case (and skill level).
And makes it standard so everything else in HA… Like an LLM if you so choose can operate it.
If it’s a collection of stuff. The llm will get confused and you don’t have a standard programattic way to access it for automation. If you use a fan class everything else automatically knows it and the UI doesn’t have to figure it out.