My instance of Home Assistant is an interface and automation engine for devices paired to various other boxes - it doesn't have any devices directly paired to it. I have Z-Wave and Zigbee devices on SmartThings and Hubitat hubs, and LightwaveRF devices on a Zipabox with 433 MHz module, which all communicate with Home Assistant through MQTT. See:
- https://github.com/stjohnjohnson/smartthings-mqtt-bridge
- https://github.com/jeubanks/hubitat-mqtt-bridge
Note that I don't necessarily think this is the best way of doing things, it's just where I ended up after playing around with the various different platforms.
I'd not spent much time writing configs for MQTT devices before it started to feel very repetitive. This is an attempt to streamline my configuration, to remove repetition, and hide some of the cross-platform weirdnesses.
configuration.yaml
should include devices in external files:
binary_sensor: !include binary_sensor.yaml
switch: !include switch.yaml
light: !include light.yaml
sensor: !include sensor.yaml
Configuration of the devices is stored in two json files: mqtt-actuators.json
and mqtt-sensors.json
.
The app.config
file contains file paths of the source (containing the two files above) and output (Home Assistant config)
directories. This should be modified with your own file paths.
Then build and run.
The actuators file contains lights, switches and heating:
[
{
"name": "Dining room light",
"platform": "smartthings",
"type": "dimmable-light",
"icon": "mdi:ceiling-light"
}
]
This would be transformed into:
### lights.yaml
# Dining room light, from smartthings via MQTT
- platform: mqtt
name: Dining room light
retain: true
state_topic: smartthings/Dining room light/switch
command_topic: smartthings/Dining room light/switch
payload_on: "on"
payload_off: "off"
brightness_state_topic: smartthings/Dining room light/level
brightness_command_topic: smartthings/Dining room light/level
brightness_scale: 99
### customize.yaml
"light.dining_room_light":
icon: mdi:ceiling-light
Valid values for type
are:
- switch
- light
- dimmable-light
- rgbw-light
- heating
The sensors file contains sensors of various types. A single device can potentially have multiple entities created in Home Assistant:
[
{
"name": "Dining room",
"platform": "hubitat",
"type": [ "motion", "temperature" ],
"deviceId": "Dining room multisensor",
}
]
This would be transformed into:
### binary_sensor.yaml
# Dining room motion, from hubitat via MQTT
- platform: mqtt
name: Dining room motion
retain: true
device_class: motion
state_topic: hubitat/Dining room multisensor/motion
payload_on: active
payload_off: inactive
### sensor.yaml
# Dining room temperature, from hubitat via MQTT
- platform: mqtt
name: Dining room temperature
retain: true
device_class: temperature
state_topic: hubitat/Dining room multisensor/temperature
unit_of_measurement: °C
force_update: true
Valid values for type
are:
- battery
- button
- contact
- motion
- presence
- temperature
The rgbw-light
doesn't work with the implementation in the two MQTT bridge repositories referenced above.
I had to customise it. I'll at some point get around to releasing or contributing my changes.
The heating
type works with a Genius Hub MQTT bridge which I've built, but not yet released. It may work
with thermostats on SmartThings or Hubitat, but I've not tested this. I've attempted to keep the same topic
names as would be generated by the other two bridges, so the chances of it working are reasonable. However,
given the nature of heating systems in this country, it's only got the heating side implemented, no cooling.