If you want to define devices, you will have to use MQTT Discovery. Whatever MQTT sensors, switches, lights, etc that you manually define in configuration.yaml
(and related files) do not accept device-related data. It states that in the device option:
device
(map)(Optional)
Information about the device this binary sensor is a part of to tie it into the device registry. Only works through MQTT discovery and whenunique_id
is set.
If you wish, you can use scripts to create entities and devices via MQTT Discovery. I provided examples in these posts:
It sounds like your irrigation server is not publishing its messages using the retained flag.
When a message is published to a topic with the retained flag, it instructs the MQTT Broker to store (retain) the message. Any MQTT client that subscribes to that topic will receive the retained message (even if the subscriber connects to the broker after the message was published).
If the message is not published with a retain flag, MQTT clients that subscribe to the topic after the message was published will receive nothing. Home Assistant is an MQTT client and, after a restart, it connects to the MQTT Broker and subscribes to all topics of interest. It receives all retained messages and for those topics whose messages were not retained, it receives nothing (i.e. unavailable
).
Given that you are the author of the irrigation server’s software, you can easily change the code so the messages are published using the retained flag.
Zigbee2mqtt publishes retained messages (that’s why they are available upon restart). You can confirm that by connecting to the MQTT Broker using a client like MQTT Explorer which indicates which topics do/don’t have retained messages.