I’m a bit new to home assistant and all it’s magic. I’ve been working on and off on automating certain things at home. I recently bought a zigbee usb stick, flashed it with zigbee2mqtt firmware and installed the zigbee2mqtt addon. I’ve install mosquitto mqtt broker and all that works fine (atleast as far as I can tell).
I have had success pairing a device to the zigbee2mqtt usb stick, zigbee2mqtt is sending it’s sensor values according to the zigbee2mqtt log:
There are two ways for Home Assistant to consume the information produced by zigbee2mqtt.
Automatic discovery
There’s an option in zigbee2mqtt to have it publish the sensor data in a way that Home Assistant will detect and automatically add (to the entity registry) as new sensors.
Manual
You define each sensor manually in the configuration file. This is more work but gives you complete control over each sensor’s definition.
If you’re not currently using either method, the sensors will not appear in Home Assistant.
Someone else using zigbee2mqtt recently required fine-grained control over the sensor’s definition so I suggested they use the manual-configuration approach:
I will look into doing it the manual way, sounds like a better option because of the control it offers.
As far as the automatic discovery, I have ‘discovery’ in hass’s configuration.yaml and ‘home assistant: true’ in zigbee2mqtt’s configuration.yaml, I assumed that would make home assistant discover the sensors/devices automatically. Is that assumption wrong?
If you are not seeing the sensors appear automatically in States page, then you should confirm zigbee2mqtt is successfully connecting to the MQTT broker.
For example, are you certain that server is set correctly here:
No I am not certain at all
I installed the mosquitto addon and zigbee2mqtt connects to it. When I modify it to something that does not exist it returns ‘not connected’.
I installed a mqtt client (mqtt.fx for mac), as far as I can tell there’s no topics. However zigbee2mqtt addon is reporting it is posting to topic “MQTT publish: topic ‘zigbee2mqtt/0x00158d0002d7781f’, payload […]”
mosquitto addon log:
1553358994: New client connected from 172.30.32.1 as e79039fd-2b4b-4fa3-98f8-d971521a51db (c1, k60).
1553360263: New client connected from xxx.xxx.xxx.xxx as MQTT_FX_Client (c1, k60).
OK. I see from the logs that both Hass.io and MQTT.fx are connecting to the the MQTT broker (i.e. the mosquitto addon). The question is “Where’s the log entry for zigbee2mqtt’s connection to the broker?”
Use MQTT.fx to subscribe to all of zigbee2matt’s topics with zigbee2mqtt/#
Now do something to make your sensors change state so published fresh payloads.
Zigbee2mqtt should be posting log entries like “MQTT publish: topic ‘zigbee2mqtt/0x00158d0002d7781f’, payload […]”
At the same moment, you should be seeing those payloads appearing in MQTT.fx.
If you’re not seeing the payloads in MQTT.fx, then I can only conclude that zigbee2mqtt is not successfully connected to the MQTT broker.
Thank you so much for thinking with me. I managed to fix the issue.
I went back to the mosquitto broker addon documentation and noticed a warning:
Since version 4.1 of the addon, an explicit ACL definition is now required, see these instructions.
I followed the steps (I did not have the /share/mosquitto folder and files) and restarted the addon. Reconnected mqtt.fx and immediately got the topics.
BUT: the sensor is nowhere to find in Home Assistant. Nothing in the entity registry. Any tips? Should I do something to have Home Assistant hace access the mqtt?
2019-09-11 14:22:30 WARNING (MainThread) [homeassistant.components.mqtt] Data in your config entry is going to override your configuration.yaml: {'broker': 'core-mosquitto', 'discovery': False, 'password': 'cxxxxxxxxxxxxxx', 'port': 1883, 'protocol': '3.1.1', 'username': 'homeassistant'}
Something was wrong on the Home Assistant integrations page. So I deleted the mqtt integration there; removed the mqtt mosquitto addon, reinstalled it and then in integrations it detected my devices.