I’m trying to figure out how to get mqtt started.
I have two Rasberry Pi’s each with it’s own Hassbian installed. One runs in the main house (hassbian1). Hassbian1 has a Vera Plus attached to it and this runs all the z wave stuff in the main house.
The other (hassbian2) runs in a shed (too far away to connect directly to the Vera Plus) and has a z wave USB stick attached to it. This runs a couple of z wave switches.
The hassbian1 has mosquito set up on it. Both HA instances have the MQTT integration set up with the broker on hassbian1).
Hasbian1 configuration.yaml has the following:
mqtt_eventstream:
publish_topic: hassbian1/topic
subscribe_topic: slaves/#
Hassbian2 configuration.yaml has the following:
mqtt_eventstream:
publish_topic: slaves/hassbian2
subscribe_topic: hassbian1/topic
I want the main HA instance (on hassbian1) to be able to control a z wave switch on hassbian2. However because this runs some machinery that I don’t want to switch on and off while I practise how to work the MQTT, I am trying to set up a binary sensor on hassbian2 that monitors the state of a light switch in the main house.
This is the MQTT message I can see in the hassbian2 log when I switch on the Utility room light in the main house:
Apr 07 23:09:08 hassbian2 hass[561]: 2019-04-07 23:09:08 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on hassbian1/topic: b’{“event_type”: “state_changed”, “event_data”: {“new_state”: {“context”: {“id”: “8a92e54df9c24180936a990dafb5bbea”, “user_id”: “823b2d1abc644f9db72cf476aff7d624”, “parent_id”: null}, “state”: “on”, “last_changed”: “2019-04-07T22:09:05.652604+00:00”, “attributes”: {“Vera Device Id”: 122, “supported_features”: 1, “friendly_name”: “Utility ceiling”, “current_power_w”: 20.9, “current_energy_kwh”: 8.96}, “entity_id”: “light.utility_ceiling_122”, “last_updated”: “2019-04-07T22:09:08.450368+00:00”}, “entity_id”: “light.utility_ceiling_122”, “old_state”: {“context”: {“id”: “8a92e54df9c24180936a990dafb5bbea”, “user_id”: “823b2d1abc644f9db72cf476aff7d624”, “parent_id”: null}, “state”: “on”, “last_changed”: “2019-04-07T22:09:05.652604+00:00”, “attributes”: {“Vera Device Id”: 122, “supported_features”: 1, “friendly_name”: “Utility ceiling”, “current_power_w”: 0.0, “current_energy_kwh”: 8.96}, “entity_id”: “light.utility_ceiling_122”, “last_updated”: “2019-04-07T22:09:05.652604+00:00”}}}’
I have added the binary_sensor as follows:
binary_sensor:
- platform: mqtt
state_topic: “hassbian1/topic”
name: Utility ceiling
Perhaps not surprisingly, nothing is happening when I switch on the Utility ceiling light.
My questions are:
- How do I identify the correct name of the Utility ceiling to put in the name: part of the binary_sensor.
- What is the correct name for the state_topic? Presumably “hassbian1/topic” can’t be correct because in the examples given on the HA website, each example has a different topic. For example:
state_topic: "home/bathroom/switch/button"
state_topic: "home-assistant/window/contact"
TIA - apologies for what is probably a really dumb set of questions. If there is a simple guide to this level of knowledge please let me know.