MQTT support

client-apps
integration
home-automation
Tags: #<Tag:0x00007fc5cf3578b0> #<Tag:0x00007fc5cf357770> #<Tag:0x00007fc5cf357630>

#41

So the homebridge-mqttthing and homebridge-mqttgaragedoor plugins got me close to having the door operate in HomeKit via MQTT, but while you can sometimes open or close close (but not always) neither are reliable about getting the status of the door.


#42

So if someone wants to get the MQTT process working with Homebridge it seems like it’s working ok now for me. Install the homebridge-mqttthing plugin, and then use the following configuration. Just replace the ExampleGarageDoor with your door name.

"accessories": [
    {
        "accessory": "mqttthing",
        "type": "garageDoorOpener",
        "name": "Garage Door",
        "url": "http://192.158.0.10:1883",
        "logMqtt": true,
        "topics": {
            "setTargetDoorState": "garadget/ExampleGarageDoor/command",
            "getTargetDoorState": {
                "topic": "garadget/ExampleGarageDoor/status",
                "apply": "return JSON.parse (message).status;"
            },
            "getCurrentDoorState": {
                "topic": "garadget/ExampleGarageDoor/status",
                "apply": "return JSON.parse (message).status;"
            }
        },
        "doorValues": [
            "open",
            "closed",
            "opening",
            "closing",
            "stopped"
        ]
    }
]

#43

I am experiencing the same behavior. I have a slow internet connection at my house and was experiencing random status changes when connected to via cloud (I assume this was cloud related). I changed to MQTT and Cloud (keeping cloud as a backup in case my server went down). My status would not update via MQTT. I switched to only MQTT and it updates correctly. I would still like the option to use both Cloud and MQTT functionality.


#44

I think this can only be resolved with a firmware upgrade.


#45

I’m trying to get my Garadget to work with HASS. I couldn’t get the Garadget cover to work so now I’m trying MQTT. I too enabled MQTT + Cloud and now my Garadget app is very slow and HASS is still not operating the Garadget or receiving status from it. I’ll try reconfiguring the Garadget for MQTT-only tomorrow.

I would also prefer to have the MQTT+cloud functionality working!


#46

MQTT+Cloud works fine on my Home Assistant 0.85.0 with Garadget Firmware v1.20
Do you get any errors in HASS logs?


#47

Thanks for your reply. I’m on HASS 0.86.4, also with Garadget firmware 1.20.

I suspect my HASS setup isn’t quite right then. There’s nothing in the log related to Garadget though I haven’t played with the log settings, assuming any errors would appear in the log with the default settings.

My HASS configuration. yaml is a combination of things I’ve found that eliminated the errors I got with the configuration on the http://www.homeassistant.io/components/cover.garadget page. I found that neither the “standard” example nor the MQTT example on that page worked for me.

@garadget, any chance you could share your working configuration (with IDs, passwords etc deidentified of course)? I suspect there’s some subtlety to the configuration that the docco hasn’t kept up with. I’ve come across other references to that possibility in my research (eg: https://github.com/home-assistant/home-assistant/issues/20420#issuecomment-457998017 ).


#48

Sure, here’s configuration.yaml

logger:
  default: warning
  logs:
    homeassistant.components.mqtt: debug

mqtt:
  password: *******


# Garadget
cover:
  - platform: mqtt
    name: "Garage Door"
    command_topic: "garadget/Home/command"
    state_topic: "garadget/Home/status"
    value_template: '{{ value_json.status }}'
    icon_template: >-
      {% if is_state('cover.garage_door', 'closed') %}
        mdi:garage-open
      {% else %}
        mdi:garage
      {% endif %}
    payload_open: "open"
    payload_close: "close"
    payload_stop: "stop"

sensor:
  - platform: mqtt
    name: 'Garage Door'
    state_topic: 'garadget/Home/status'
    value_template: '{{ value_json.status }}'
    icon_template: '{% if is_state("sensor.garage_door", "closed") %}mdi:garage{% else %}mdi:garage-open{% endif %}'

  - platform: mqtt
    name: 'Garage Brightness'
  state_topic: 'garadget/Home/status'
    unit_of_measurement: '%'
    value_template: '{{ value_json.bright }}'

#49

Thanks Denis,

I’ll tweak my settings to match yours when I get home from work later today.

BTW, I use the “secrets.yaml” file for my passwords. I assume there’s no problem with doing that for the mqtt password?

Cheers,

Rob Hills
Waikiki, Western Australia


#50

Hi Denis,

I’ve tweaked my configuration to match yours, but I’m still not quite there. Part of my original problem was that I’d missed making a pinhole in my firewall between LAN and WiFi networks for MQTT traffic but I’ve sold now. What I see in the log now (with debug turned on) is the following:

2019-02-05 00:30:22 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to garadget/My_Street/status
2019-02-05 00:30:22 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to garadget/My_Street/status
2019-02-05 00:30:22 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to garadget/My_Street/status
2019-02-05 00:35:17 ERROR (MainThread) [hbmqtt.broker] Invalid connection from (client @=192.168.23.157:12218) : [MQTT-3.1.2-1] Incorrect protocol name: "MQIsdp"
2019-02-05 00:36:14 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on garadget/My_Street/command: close

I’m not sure why I’m getting the “Incorrect Protocol” error.

I don’t see any status change in response to the “close” command and the door doesn’t close.

TIA,

Rob
Waikiki, Western Australia


#51

I’ve upgraded HA to 0.86.4 and here’s the relevant log from the first boot (looks healthy):

|2019-02-04 16:50:21|stdout|e[36m2019-02-04 09:50:21 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on garadget/Home/status: b'{"status":"closed","time":"102m","sensor":97,"bright":11,"signal":-41}'e[0m|
|2019-02-04 16:50:21|stdout|e[36m2019-02-04 09:50:21 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to garadget/Home/statuse[0m|
|2019-02-04 16:50:21|stdout|e[36m2019-02-04 09:50:21 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on garadget/Home/status: b'{"status":"closed","time":"102m","sensor":97,"bright":11,"signal":-41}'e[0m|
|2019-02-04 16:50:21|stdout|e[36m2019-02-04 09:50:21 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on garadget/Home/status: b'{"status":"closed","time":"102m","sensor":97,"bright":11,"signal":-41}'e[0m|
|2019-02-04 16:50:21|stdout|e[36m2019-02-04 09:50:21 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to garadget/Home/statuse[0m|
|2019-02-04 16:50:21|stdout|e[36m2019-02-04 09:50:21 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to garadget/Home/statuse[0m|

Re. white spaces in name: I don’t find anything about them not being allowed, but I’d at least test with SomeStreet as the name. For debugging you can try getting mosquitto broker and use their client to manually connect/subscribe with home assistant and see if there are any errors.


#52

Hi Denis,

Thanks for your reply. Sorry, but I suspect I updated my post while you were writing the reply. I discovered and fixed a firewall issue and now I have a new problem (see updated previous post).

It may respond to the Mosquitto broker suggestion, but I figured if yours works with the inbuilt mqtt broker, mine should too ?

Cheers,

Rob


#53

Please try using the password setting as in my config, at least to rule out that as the source of the error.


#54

Hi Denis,

I notice in your log it says Subscribing to garadget/Home/statuse rather than “status”. Can you confirm that your state_topic value is “garadget/Home/status” and not “garadget/Home/statuse”? I suspect the log output is some sort of log formatting anomaly, but thought I’d check.

I’ve tried moving the mqtt password from secrets.yaml into the main configuration.yaml file but the only change I’ve seen since then, which may or may not be related, is that I’ve now lost the “incorrect protocol name” error I was getting before. Still no status messages in the log and no response to attempts to open it.

I changed back to my original configuration (with the password in secrets.yaml) and now have the same outcome as the previous step: no “incorrect protocol name” but no status messages, no response to attempts to open it.

I think the next step will be to try changing the ID on the Garadget itself from “My Street” to “MyStreet” as you mentioned previously.

Cheers,

Rob Hills
Waikiki, Western Australia


#55

Not getting protocol error message is already a positive result. I’d keep that version while trying to make other things to work. Then when everything works it would be a good time to figure out the way to separate the password.