First time user here to play with HA, coming from another home automation system.
I’m trying to add my old Automower to HA from MQTT.
It sends the various values as sub topics, not a json, like this:
How do I combine this to one single “device”?
I have added it as a sensor, just to start with:
The word “device” has special meaning in Home Assistant. It typically refers to a physical device that is represented by one or more entities. For example, the Philips Hue bridge is a device and each Hue light is represented as a separate light entity. Here’s another example, my laser printer is a device and all of its characteristics (toner level, page count, etc) are represented as separate entities:
Another way to model something is to represent it as a single entity with multiple attributes. For example, here’s sun.sun. Its state (above_horizon) is the current state of the sun and all other characteristics (elevation, next_dawn, etc) are reported as attributes.
Thanks for explanation. Are there any drawback in using device or entities, when using them later on in automation etc? based on your explanation I would go for one entity with multiple attributes. I also want to map the status numbers to decriptive text.
There are no drawbacks in using devices or entities (unless you consider it a drawback to seeing each one of Autommower’s sub-topics exposed as a separate entity in Configuration > Entities). One advantage to this arrangement (as I’ve explained above) is that it reveals information about the physical device. The other advantage is that each sub-topic is a separate entity so that’s useful if you plan to create automations that need to trigger on any of those sub-topics.
The advantage of modeling it as entity with attributes is compactness (it’s a single entity). It’s still possible to create automations that trigger when an entity’s attribute changes but it’s not as neat as with separate entities.
You should know that it will be challenging to create an entity with attributes based on multiple MQTT topics. An MQTT Sensor offers json_attributes_topic to subscribe to a single topic and json_attributes_template to convert the JSON payload into one or more attributes. Your Automower’s multiple topics can’t be used with this arrangement. You might have to use an external program to subscribe to all the topics and re-package all the data into a single topic with a JSON payload (i.e. into something that Home Assistant knows how to easily process).
All this to say that Automower’s multiple topics may oblige you to model it as a device with many entities