Hi, I am using two instances of HA, one in the office and the other one at home (both on Synology in Docker-Containers). The Networks of the office and home are linked with a VPN. In the office i use multiple door-and-window-sensors from Xiaomi with an Aqara Hub. Now I want to know the status of the sensors (on/off) from the office in the HA-instance at home, so that i can create automations with that stats (e.g. start the light in the bedroom at home when the door in the office is opened during the night. For that i installed Mosquitto on my Synology at home in a docker-container and added in both configuration.yaml:
#MQTT Broker
mqtt:
broker: xxx.xxx.xxx.xxx
port: 1883
But now i don’t know what to do further. How is the next step on the HA instance in the office and at home so that i can see the door sensor from office in the instance at home?
Happy for help!
Have a look at
Should do what you’re after
I just need 8-10 sensors so i don’t wanted to use state stream as a bit overpowered.
In the automation.yaml in the office I use this automation for a door-sensor:
- id: '7245276456274576762452'
alias: Send Status Door to MQTT
trigger:
- platform: state
entity_id:
- binary_sensor.door_and_window_sensor_ada2
action:
- service: mqtt.publish
data:
topic: 'office/sensoren/door'
payload_template: |
{% if is_state("binary_sensor.door_and_window_sensor_ada2", "on") %} on
{% elif is_state("binary_sensor.door_and_window_sensor_ada2", "off") %} off
{% endif %}
retain: true
qos: 1
As I can see in the Developer Tools in the HA-instance at home the Status of the door arrives there correctly (on/off). But the binary_sensor I defined in the HA-instance at home gets no update and always shows “closed”. I defined it like that:
# binary_sensor door
- platform: mqtt
state_topic: "/office/sensoren/door"
name: 'Door'
force_update: true
qos: 1
payload_on: "on"
payload_off: "off"
device_class: door
Maybe that there is something wrong with my definition of the binary_Sensor. Can someone tell me my error?
While I wrote the last post I was able to find the error by myself. There was one Backslash to much in the state_topic so that there can’t come any information…
Without that backslash it seems to be fine:
# binary_sensor door
- platform: mqtt
state_topic: "office/sensoren/door"
name: 'Door'
force_update: true
qos: 1
payload_on: "on"
payload_off: "off"
device_class: door