MQTT

system: device provider: hub/mqtt introduced in v0.1 pubSub

MQTT is a very popular messaging protocol for IoT devices. go-home uses Paho client therefore supports all major MQTT versions.

Configuration options

Param Required Type Default Description
broker yes string MQTT broker address without mqtt:// prefix
clientID string gohome Clint ID to use. If you have configured acl’s in you broker, make sure you’re using correct clientID
login string Login to use for broker connection
password string Password to use for broker connection
topicsPrefix string Common prefix to use for every topic
devices yes [device] List of devices to instantiate

Device

Param Required Type Default Description
type yes string Device type
sensorType string If device is a sensor, you can specify its type
name yes string Device name. You still can override this through nameOverrides, however it doesn’t make a lot of sense to do so
qos int 2 Quality of service
retained bool false Flag indicating whether commands messages for this device should be posted as retained
pessimistic bool false Flag indicating whether device should use pessimistic mode. In this mode, after using any command, device is not waiting for the update message from the broker and sets it’s internal state automatically to whatever was received from a command
units string imperial Metric or imperial system to use for this device (if required for the device)
properties [property] List of mapped properties
commands [command] List of mapped commands

Property

Param Required Type Default Description
topic yes string Topic name
property yes string Property name
mapper yes string Property read mapper

Command

Param Required Type Default Description
topic yes string Topic name
command yes string Command name
mapper yes string Command write mapper

Supported devices

  • sensor
  • switch

Supported properties

Depends on a device

Supported commands

Depends on a device

Example

The following example shows how to integrate with a SmartThings bridge:

system: device
provider: hub/mqtt
name: samsung
login: gohome
password: password
clientID: gohome
broker: mq-volantmq.default.svc.cluster.local:1883
topicsPrefix: smartthings/
devices:
  - type: switch
    name: cabinet lamp
    qos: 2
    properties:
      - property: "on"
        topic: CabinetLamp/switch/state
        mapper: payload == 'on'
    commands:
      - command: "on"
        topic: CabinetLamp/switch/cmd
        mapper: str('on')
      - command: "off"
        topic: CabinetLamp/switch/cmd
        mapper: str('off')
  - type: sensor
    qos: 1
    name: cabinet lamp
    properties:
      - property: power
        topic: CabinetLamp/power/state
        mapper: num(payload)
  - type: sensor
    qos: 1
    name: restroom
    properties:
      - property: "on"
        topic: MotionRestroom/motion/state
        mapper: payload == 'active'
      - property: temperature
        topic: MotionRestroom/temperature/state
        mapper: num(payload)
      - property: battery_level
        topic: MotionRestroom/battery/state
        mapper: num(payload)