MQTT support

New firmware with MQTT support is ready for testing!
Those interested in early access, please Please PM me your device IDs.

After the firmware has been updated over-the-air, please access configuration interface:

  1. Put your unit into listening mode: press and hold “M” button for about 3 seconds until LED starts blinking dark blue.
  2. Connect any WiFi enabled device to PHOTON-XXXX access point.
  3. Open http://192.168.0.1/ in the browser and (re-)configure WiFi connection and MQTT settings
  4. Submit to save. The device will reconnect to your WiFi network.

This process can be repeated anytime if necessary. Internet connection is not required.
Note that either or both Cloud and MQTT links can be used.
This firmware can be reversed if something doesn’t work out right.
The code was tested with Mosquitto broker, but should work with Home Assistant or any other standard MQTT client.

3 Likes

What are the MQTT command topics?

Following topics are supported:

/garadget/{device-name}/status
/garadget/{device-name}/command

{device-name} is configured in the setup
First topic is used by Garadget to send the door status updates (you’ll received open/closed/stopped as payload)
Second is used by Garadget to receive door commands (you can send open/close/stop)

If you are a home assistant user the configuration in HA will look like this:

cover:

  • platform: mqtt
    name: "Garage Door"
    command_topic: "garadget/device_name/command"
    state_topic: "garadget/device_name/status"
    payload_open: "open"
    payload_close: “close”

Status Sensor:

  • platform: template
    sensors:
    garage_door_status:
    friendly_name: 'Garage Door State’
    value_template: '{{ states.cover.garage_door.state }}'
    icon_template: ‘{% if is_state(“cover.garage_door”, “closed”) %}mdi:garage{% else %}mdi:garage-open{% endif %}’
1 Like

New Version!

New firmware version (1.20) with MQTT support has been deployed.

Change Log (1.19)

  • Recent versions of Home Assistant’s internal MQTT broker users protocol version 3.1.1 which expects a different handshake from the client and rejects the connection otherwise. The new version of firmware alternately tries to connect using protocol v3.1 and v3.1.1 until succeeds.
  • Added light brightness sensor in case somebody wants to use in automation or just for reporting
  • Implemented device configuration via MQTT calls with JSON payloads
  • Updated payload formats for some of the calls
  • Sensor reads parameter deprecated in UI and hard-coded at 3.

Change Log (1.20)

  • Fixed timeout alert
  • Re-organized MQTT topics

Initial Configuration

After you confirmed in settings that your Garadget is at at v1.20 use the following process to configure MQTT connection.

  1. Put your unit into listening mode: press and hold “M” button for about 3 seconds until LED starts blinking dark blue.
  2. Connect any WiFi enabled device to PHOTON-XXXX access point.
  3. Open http://192.168.0.1/ in the browser and (re-)configure WiFi connection and MQTT settings
  4. Submit to save. The device will reconnect to your WiFi network.

Same process can be used to re-setup the device with new WiFi network or to change any of the configuration settings without internet connection and mobile apps.

MQTT Topics

Garadget subscribes for following topics:

/garadget/{device-name}/command

Acceptable payloads:

  • open - to open the door
  • close - to close the door
  • stop - to stop the door if in motion
  • get-config - to request the config update posted to config topic (see below)
  • get-status - to request the status update posted to status topic (see below)

/garadget/{device-name}/set-config

Acceptable payload is JSON with any combination of following properties:

  {"rdt":num,"mtt":num,"rlt":num,"rlp":num,"srt":num,"nme":"str","mqtt":num,"":"str","mqpt":str,"mqus":"str","mqto":num}
  • rdt - sensor scan interval in mS (200-60,000, default 1,000)
  • mtt - door moving time in mS from completely opened to completely closed (1,000 - 120,000, default 10,000)
  • rlt - button press time mS, time for relay to keep contacts closed (10-2,000, default 300)
  • rlp - delay between consecutive button presses in mS (10-5,000 default 1,000)
  • srt - reflection threshold below which the door is considered open (1-80, default 25)
  • nme - device name to be used in MQTT topic. If cloud connection enabled, at reboot this value will be overwritten with the one saved in cloud via the apps
  • mqtt - bitmap 0x01 - cloud enabled, 0x02 - mqtt enabled, 0x03 - cloud and mqtt enabled
  • mqip - MQTT broker IP address
  • mqpt - MQTT broker port number
  • mqus - MQTT user
  • mqto - MQTT timeout (keep alive) in seconds

Garadget publishes to the following topics

/garadget/{device-name}/status

At the boot, reconnect, when status changed or when requested with the get-status command (see above). The payload is the JSON like this:

{"status":"str","time":"str","sensor":num,"bright":num,"signal":num}
  • status - status of the door (open/closed/stopped)
  • time - time in status (10s, 20m, 15h, 10d etc)
  • sensor - reflection rate (0-99)
  • bright - ambient light brightness (0-99)
  • signal - WiFi signal strength in dB e.g. -40

/garadget/{device-name}/config

At the boot, reconnect, when configuration changed or when requested with the get-config command (see above). The payload is the same as that of get-config command but with additional read-only properties:

  • sys - Particle system firmware version
  • ver - Garadget firmware version (1.19)
  • id - Garadget/Particle device ID
  • ssid - WiFi access point (network) name

Below is the Home Assistant configuration code that seems to work for me. I’m poking at it for only few days so anybody with experience is welcome to suggest improvements (icons, etc).

create cover in configuration.yaml

cover:
  - platform: mqtt
    name: "Garage Door"
    command_topic: "garadget/Home/command"
    state_topic: "garadget/Home/status"
    payload_open: "open"
    payload_close: "close"

in sensors.yaml linked from configuration.yaml with sensor: !include sensors.yaml

- platform: mqtt
  name: 'Garage Door'
  state_topic: 'garadget/Home/status'
  value_template: '{{ value_json.status }}'

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

in automations.yaml periodically request the status to keep the brightness updated

- alias: 'Update Garage Brightness'
  trigger:
    platform: time
    minutes: '/2'
    seconds: 00
  action:
    service: mqtt.publish
    data:
      topic: "garadget/Home/command"
      payload: "get-status"

Your feedback and suggestions are very welcome.

2 Likes

A post was split to a new topic: MQTT firmware request

Love this so much guys, great work. Put it to use right away! Thanks heaps

1 Like

Ohhh…here’s hoping for a new smartthings smartapp & DTH!!!

This is really great! I have a unit from the Kickstarter and have been waiting until a local-only mode was working. MQTT was a great idea and will fit easily with my existing systems as I already use MQTT for other things.

Is there (or will there be) a way to update the firmware without bringing the device on-line at all? Can you send me or post the firmware to update locally? Or is that something that must be done via the cloud?

Thanks, both for any answer you can give, and for trying to add this feature!

1 Like

Yes, you can upload firmware locally via USB. Source and Binary are available.

1 Like

That’s perfect! Those directions are just what I needed. I’ll give it a try this weekend. Thanks so much!

1 Like

Hello. to make the cover to work better with homebridge i had to add this line in the HASS-configuration:
value_template: '{{ value_json.status }}'
Else i couldn’t open or close the garage via my phone as the state of the door was unknown. It also removed this error message in the log file:
2018-02-07 00:26:00 WARNING (MainThread) [homeassistant.components.cover.mqtt] Payload is not True, False, or integer (0-100): {"status":"closed","time":"15m","sensor":98,"bright":10,"signal":-11}

1 Like

Thomas,
Thanks for the update. Can you please post the complete configuration as you have it?

Still seeing the cover component in an ‘unknown’ state. Here is my cover config in HA.

cover:
  • platform: mqtt
    name: "Garage Door"
    command_topic: "garadget/Timbertrail/command"
    state_topic: "garadget/Timbertrail/status"
    payload_open: "open"
    payload_close: "close"
    value_template: ‘{{ value_json.status }}’

Please see the HA’s logs to confirm that the events are coming in and the topic is correct.

It is mainly on a restart of HA. The cover component will show a status of unknown even if the mqtt sensor has a status of open or closed. The cover used to show the correct status in the previous version of the firmware.

This is working correctly in my setup, wondering what the difference.
Do you get the correct status after door opens/closes?

Yes, on a restart the UP and DOWN arrows in HA are both available. If I select the down for close then the right status is displayed in the cover. The sensor is poling every 2 min to get the status. I also notice if left for a while the status will go to an unknown. This is running in MQTT mode only.

Do you get the correct status populated if you operate the door outside of the HA (e.g. with wall button)?
Please see if this help shedding some light on the issue.

I’m using MQTT only and Home Assistant. Everything is working great! Just had a little hiccup - needed to open the garadge door using wall panel for status in HA to update.

Working well. :slight_smile:

1 Like