Garadget, MQTT, Node-RED, Home Assistant, Homekit (or any other voice assistant with HA)

As requested, here a quick guide on integrated Garadget with MQTT, Node-RED, Home Assistant.

You will need to install the custom component in HA for Node-RED. I installed this via HACS.

This allows Node-RED to create entities into HA. e.g. a Sensor.

Some of my Node-RED flow may be over the top, however I have cleaned up some of the formatting so it presents nicely into HA. It also includes the icons and unit of measure.

There is also a rolling 1min poll of the status to update the sensors, the RDE node make it that only changes are reported to the HA sensors. The status update is also triggered when the door is “open” or “closed”.

The reason for the open or closed sensor separately is to remove any issues around the status being unknown and it seems that Homekit only likes it “open” or “closed”

Here is the code for Node-RED, you can update the topic and MQTT server info.

Node-RED.txt (11.5 KB)

Here is my configuration.yaml

cover:
  - platform: mqtt
    name: "Garage Door MQTT"
    device_class: 'garage'
    command_topic: "garadget/Garage/command"
    state_topic: "garadget/Garage/status"
    value_template: "{{ states('sensor.node_red_garage_door_open_or_closed') }}"
    payload_open: "open"
    payload_close: "close"
    payload_stop:

I have the payload for “stop” removed, leaving it blank removes the option to stop the door. I had issues with the stop command simply making my door go back down. It was simple to just remove it and let it go completely up or down.

image

Lovelace Card config:

type: entities
entities:
  - entity: cover.garage_door_mqtt
    name: Garage Door
  - entity: sensor.node_red_garage_door_state
    name: State
  - entity: sensor.node_red_garage_door_time_in_state
    name: Time in State
  - entity: sensor.node_red_garage_door_sensor_reflection_rate
    name: Sensor Reflection Rate
  - entity: sensor.node_red_garage_ambient_light_brightness
    name: Ambient Light Brightness
  - entity: sensor.node_red_garage_door_wifi_signal
    name: Wifi Signal
title: Garage Door

I have Homekit integrated with HA and the door works perfectly.

1 Like

slight update:

With the above configuration, I had that Home Assistant could only operate up or down. No stop commands.

However if the button is pressed in Homekit multiple times it can cause issues. I now have a check on the command so it can only go up or down via checking the state first.

HA sends MQTT commands to NodeRED, NodeRED updates HA on the state of the Garage.

NodeRED talks to Garadge via MQTT

It is also a little more simple than above, with the opening closing status also correctly tracked via HA as I can filter that information via NodeRED.

Home Assistant now shows the icon changes when opening / closing.

You can simply copy what I have, just make sure your topics are updated and server info.

[{"id":"103cc67.8a2a33a","type":"mqtt in","z":"53aabe5c.55603","name":"","topic":"garadget/Garage/status","qos":"2","datatype":"utf8","broker":"4d42f578.4cd4ac","x":180,"y":480,"wires":[["9a03810b.daabf"]]},{"id":"d9c45e63.3f094","type":"mqtt out","z":"53aabe5c.55603","name":"","topic":"garadget/Garage/command","qos":"2","retain":"","broker":"4d42f578.4cd4ac","x":1660,"y":840,"wires":[]},{"id":"8a1f7e79.9715a","type":"inject","z":"53aabe5c.55603","name":"","props":[{"p":"payload"}],"repeat":"60","crontab":"","once":true,"onceDelay":"0","topic":"","payload":"get-status","payloadType":"str","x":1370,"y":760,"wires":[["d9c45e63.3f094"]]},{"id":"9a03810b.daabf","type":"json","z":"53aabe5c.55603","name":"","property":"payload","action":"","pretty":false,"x":370,"y":480,"wires":[["452f6560.cc4e7c","ec717606.a82b18","df68cd3a.5620b","fbbcffad.76bf5","f3a60b8c.d33228"]]},{"id":"fbbcffad.76bf5","type":"change","z":"53aabe5c.55603","name":"Garage Ambient Light Brightness","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.bright","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":480,"wires":[["ae035efe.81b26"]]},{"id":"f3a60b8c.d33228","type":"change","z":"53aabe5c.55603","name":"Wifi Signal","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.signal","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":560,"wires":[["41381105.63a09"]]},{"id":"41381105.63a09","type":"rbe","z":"53aabe5c.55603","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":870,"y":560,"wires":[["1c3fea87.71a365"]]},{"id":"ae035efe.81b26","type":"rbe","z":"53aabe5c.55603","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":870,"y":480,"wires":[["1ad94266.96dfbe"]]},{"id":"ec717606.a82b18","type":"change","z":"53aabe5c.55603","name":"Time in State","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":320,"wires":[["a2eca8de.38ba98"]]},{"id":"df68cd3a.5620b","type":"change","z":"53aabe5c.55603","name":"Garage Sensor","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.sensor","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":400,"wires":[["1369d041.cd7bb"]]},{"id":"1369d041.cd7bb","type":"rbe","z":"53aabe5c.55603","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":870,"y":400,"wires":[["45a076f4.547c48"]]},{"id":"a2eca8de.38ba98","type":"rbe","z":"53aabe5c.55603","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":870,"y":320,"wires":[["930d9ec2.0a584"]]},{"id":"452f6560.cc4e7c","type":"change","z":"53aabe5c.55603","name":"Garage State","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.status","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":640,"wires":[["fbffadd2.3b908","bbf82f95.bea51"]]},{"id":"7ae47241.c6ad7c","type":"mqtt in","z":"53aabe5c.55603","name":"","topic":"garadget/Garage/command","qos":"2","datatype":"utf8","broker":"4d42f578.4cd4ac","x":200,"y":140,"wires":[["628ec43e.083e6c"]]},{"id":"628ec43e.083e6c","type":"debug","z":"53aabe5c.55603","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":140,"wires":[]},{"id":"a6c5f13.44eea1","type":"ha-entity","z":"53aabe5c.55603","name":"Garage Door State","server":"613f67e5.e69a28","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Node-RED Garage Door State"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:garage-alert"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1530,"y":640,"wires":[[]]},{"id":"6da1fc03.c126f4","type":"ha-entity","z":"53aabe5c.55603","name":"Garage Door Time in State","server":"613f67e5.e69a28","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Node-RED Garage Door Time in State"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:timer"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1560,"y":320,"wires":[[]]},{"id":"45a076f4.547c48","type":"ha-entity","z":"53aabe5c.55603","name":"Garage Door Sensor Reflection Rate","server":"613f67e5.e69a28","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Node-RED Garage Door Sensor Reflection Rate"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:laser-pointer"},{"property":"unit_of_measurement","value":"%"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1590,"y":400,"wires":[[]]},{"id":"1ad94266.96dfbe","type":"ha-entity","z":"53aabe5c.55603","name":"Garage Ambient Light Brightness","server":"613f67e5.e69a28","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Node-RED Garage Ambient Light Brightness"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:brightness-percent"},{"property":"unit_of_measurement","value":"%"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1580,"y":480,"wires":[[]]},{"id":"1c3fea87.71a365","type":"ha-entity","z":"53aabe5c.55603","name":"Garage Door Wifi Signal","server":"613f67e5.e69a28","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Node-RED Garage Door Garage Door Wifi Signal"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:wifi"},{"property":"unit_of_measurement","value":"dB"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1550,"y":560,"wires":[[]]},{"id":"23e8e7f3.39a128","type":"change","z":"53aabe5c.55603","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"open","fromt":"str","to":"Open","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"closed","fromt":"str","to":"Closed","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"opening","fromt":"str","to":"Opening","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"closing","fromt":"str","to":"Closing","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"stopped","fromt":"str","to":"Stopped","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":640,"wires":[["a6c5f13.44eea1"]]},{"id":"930d9ec2.0a584","type":"switch","z":"53aabe5c.55603","name":"","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"s","vt":"str","case":false},{"t":"regex","v":"m","vt":"str","case":false},{"t":"regex","v":"h","vt":"str","case":false},{"t":"regex","v":"d","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":4,"x":1050,"y":300,"wires":[["c58dacd2.f6979"],["ffbeeacc.149518"],["301b6844.340c18"],["f1c84bf2.727868"]]},{"id":"ffbeeacc.149518","type":"change","z":"53aabe5c.55603","name":"Minutes","rules":[{"t":"change","p":"payload","pt":"msg","from":"m","fromt":"str","to":" Minutes","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":240,"wires":[["6da1fc03.c126f4"]]},{"id":"c58dacd2.f6979","type":"change","z":"53aabe5c.55603","name":"Seconds","rules":[{"t":"change","p":"payload","pt":"msg","from":"s","fromt":"str","to":" Seconds","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":200,"wires":[["6da1fc03.c126f4"]]},{"id":"301b6844.340c18","type":"change","z":"53aabe5c.55603","name":"Hours","rules":[{"t":"change","p":"payload","pt":"msg","from":"h","fromt":"str","to":" Hours","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":280,"wires":[["6da1fc03.c126f4"]]},{"id":"f1c84bf2.727868","type":"change","z":"53aabe5c.55603","name":"Days","rules":[{"t":"change","p":"payload","pt":"msg","from":"d","fromt":"str","to":" Days","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":320,"wires":[["6da1fc03.c126f4"]]},{"id":"fbffadd2.3b908","type":"rbe","z":"53aabe5c.55603","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":870,"y":640,"wires":[["23e8e7f3.39a128"]]},{"id":"dbc0234.12513e","type":"comment","z":"53aabe5c.55603","name":"Poll Status Every 60 Secs","info":"","x":1330,"y":720,"wires":[]},{"id":"bf3b359d.1a1e88","type":"api-current-state","z":"53aabe5c.55603","name":"Garage Door Closed?","server":"613f67e5.e69a28","version":1,"outputs":2,"halt_if":"closed","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"cover.garage_door_mqtt","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1140,"y":800,"wires":[["87ecae59.f487a"],[]]},{"id":"8c0ed406.476668","type":"api-current-state","z":"53aabe5c.55603","name":"Garage Door Open?","server":"613f67e5.e69a28","version":1,"outputs":2,"halt_if":"open","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"cover.garage_door_mqtt","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1140,"y":880,"wires":[["e00344ed.566978"],[]]},{"id":"87ecae59.f487a","type":"change","z":"53aabe5c.55603","name":"Open Garage","rules":[{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1360,"y":800,"wires":[["d9c45e63.3f094"]]},{"id":"e00344ed.566978","type":"change","z":"53aabe5c.55603","name":"Close Garage","rules":[{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1360,"y":880,"wires":[["d9c45e63.3f094"]]},{"id":"b9e57d24.80b1c","type":"mqtt in","z":"53aabe5c.55603","name":"","topic":"nodered/Garage/command","qos":"2","datatype":"utf8","broker":"4d42f578.4cd4ac","x":610,"y":840,"wires":[["4fdc9198.65939"]]},{"id":"4fdc9198.65939","type":"switch","z":"53aabe5c.55603","name":"Open or Close","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"open","vt":"str"},{"t":"eq","v":"close","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":880,"y":840,"wires":[["bf3b359d.1a1e88"],["8c0ed406.476668"]]},{"id":"9df3db3c.d07ee8","type":"inject","z":"53aabe5c.55603","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"open","payloadType":"str","x":670,"y":880,"wires":[["4fdc9198.65939"]]},{"id":"f6e4e3a1.e133e","type":"inject","z":"53aabe5c.55603","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"close","payloadType":"str","x":670,"y":920,"wires":[["4fdc9198.65939"]]},{"id":"bbf82f95.bea51","type":"switch","z":"53aabe5c.55603","name":"Open, Closed, Opening & Closing","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"open","vt":"str"},{"t":"eq","v":"closed","vt":"str"},{"t":"eq","v":"opening","vt":"str"},{"t":"eq","v":"closing","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":640,"y":740,"wires":[["27d98cc8.1e2f54"],["27d98cc8.1e2f54"],["27d98cc8.1e2f54"],["27d98cc8.1e2f54"]]},{"id":"27d98cc8.1e2f54","type":"mqtt out","z":"53aabe5c.55603","name":"","topic":"nodered/Garage/status","qos":"2","retain":"","broker":"4d42f578.4cd4ac","x":1080,"y":740,"wires":[]},{"id":"4d42f578.4cd4ac","type":"mqtt-broker","name":"","broker":"192.168.0.10","port":"1883","clientid":"Node-RED","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"613f67e5.e69a28","type":"server","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

  - platform: mqtt
    name: "Garage Door MQTT"
    device_class: 'garage'
    command_topic: "nodered/Garage/command"
    state_topic: "nodered/Garage/status"
    payload_open: "open"
    payload_close: "close"
    payload_stop:

The lovelace config is still the save as above.