### Install homebridge-mqttthing Globally Source: https://github.com/arachnetech/homebridge-mqttthing/blob/master/README.md Install the plugin globally using npm. This is the recommended method for server-wide installation. ```bash npm install -g homebridge-mqttthing ``` -------------------------------- ### JSON Codec Example Configuration Source: https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Codecs.md An example accessory configuration demonstrating the use of the JSON codec for a lightbulb. It maps 'on' and 'RGB' properties and includes fixed values for version and sender. ```json { "accessory": "mqttthing", "type": "lightbulb", "name": "Test RGB Light", "url": "mqtt://192.168.10.35:1883", "topics": { "getRGB": "test/rgblight/get", "setRGB": "test/rgblight/set", "getOn": "test/rgblight/get", "setOn": "test/rgblight/set" }, "logMqtt": true, "integerValue": false, "codec": "json", "jsonCodec": { "properties": { "on": "state.power", "RGB": "state.rgb" }, "fixed": { "version": 1, "sender": "MQTT-Thing" } } } ``` -------------------------------- ### Shelly AMAX Codec Example Configuration Source: https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Codecs.md Example configuration for integrating a Bosch AMAX alarm system with Shelly switches using the shellyAMAX codec. This setup requires specific mappings for setting and getting alarm states. ```json { "name": "AMAX", "accessory": "mqttthing", "url": "url", "username": "user", "password": "passwd", "type": "securitySystem", "codec": "shellyAMAX", "ShellyGen": 1, "AMAX": { "setState": { "Armed": { "name": "shellies/shellyuni-98CDAC25XXXX", "id": 0, "ACTIVE": "on" }, "Disarmed": { "name": "shellies/shellyuni-98CDAC25XXXX", "id": 0, "ACTIVE": "on" } }, "getState": { "Armed": { "name": "shellies/shellyuni-98CDAC25XXXX", "id": 0, "ACTIVE": 1 }, "Triggered": { "name": "shellies/shellyuni-98CDAC25XXXX", "id": 1, "ACTIVE": 0 }, "AltTriggered": { "name": "shellies/shellyuni-98CDAC25XXXX", "id": 1, "ACTIVE": 1 } } }, "targetStateValues": [ "SA", "AA", "NA", "D" ], "currentStateValues": [ "SA", "AA", "NA", "D", "T" ], "restrictTargetState": [ 1, 3 ], "logMqtt": true } ``` -------------------------------- ### General Configuration for Homebridge MQTT-Thing Source: https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Configuration.md This is a comprehensive example of a typical configuration for a lightbulb accessory using Homebridge MQTT-Thing. It includes common settings for MQTT connection, topics, and accessory behavior. ```javascript { "accessory": "mqttthing", "type": "lightbulb", "name": "My lightbulb", "url": "mqtt://192.168.1.235:1883", "username": "MQTT_username", "password": "MQTT_password", "mqttOptions": { "keepalive": 30 }, "mqttPubOptions": { "retain": false }, "logMqtt": true, "topics": { "getName": "my/get/name/topic", "getOnline": "my/get/online/topic", "getBatteryLevel": "my/get/battery-level/topic", "getChargingState": "my/get/battery-charging-state/topic", "getStatusLowBattery": "my/get/status-low-battery/topic" }, "integerValue": true, "onlineValue": "Online", "offlineValue": "Offline", "chargingStateValues": [ "NotCharging", "Charging", "NotChargeable" ], "startPub": [ { "topic": "topic1", "message": "message1" }, { "topic": "topic2", "message": "message2" } ], "confirmationPeriodms": 1000, "retryLimit": 5, "debounceRecvms": 200, "optimizePublishing": false, "validate": true } ``` -------------------------------- ### Configure Speaker with MQTTThing Source: https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Accessories.md Configure a speaker accessory to control mute and volume via MQTT. Specify the topics for getting and setting these states. ```json { "accessory": "mqttthing", "type": "speaker", "name": "", "topics": { "getMute": "", "setMute": "", "getVolume": "", "setVolume": "" } } ``` -------------------------------- ### Configure Shelly RGBW2 Color for mqttthing Source: https://github.com/arachnetech/homebridge-mqttthing/wiki/Tested-Configurations Example configuration for Shelly RGBW2 Color, supporting dimming and fade transitions. Set the MQTT URL and device name, and configure topics for color control. ```json { "accessory": "mqttthing", "type": "lightbulb", "name": "Shelly RGBW2", "url": "mqtt://192.168.0.200:1883", "logMqtt": false, "topics": { "getOn": "shellies/shelly-xxx/color/0", "setOn": "shellies/shelly-xxx/color/0/command", "getRGBW": { "topic": "shellies/shelly-xxx/color/0/status", "apply": "const response = JSON.parse(message); return response.red.toString() + ',' + response.green.toString() + ',' + response.blue.toString() + ',' + response.white.toString();" }, "setRGBW": { "topic": "shellies/shelly-xxx/color/0/set", "apply": "if (message == '0,0,0,0') { return JSON.stringify({ 'turn': 'off', 'transition': 3000 }); } else { const splitMessage = message.split(','); return JSON.stringify({ 'turn': 'on', 'red': splitMessage[0], 'green': splitMessage[1], 'blue': splitMessage[2], 'white': splitMessage[3], 'gain': 100, 'transition': 4000 })" } }, "onValue": "on", "offValue": "off", "adaptiveLighting": false, "optimizePublishing": true, "debounceRecvms": 250 } ``` -------------------------------- ### Mosquitto MQTT Broker Configuration Source: https://github.com/arachnetech/homebridge-mqttthing/wiki/Tested-Configurations Example configuration settings for the Mosquitto MQTT broker to handle persistent messages and auto-saving. ```ini autosave_interval 1800 autosave_on_changes false persistence true persistence_file mosquitto.db persistence_location /mosquitto/data/path/ etc. ``` -------------------------------- ### Thermostat Configuration Example Source: https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Accessories.md This JSON configuration defines a thermostat accessory using MQTTThing. Specify topics for reporting and controlling various thermostat states and values. Optional fields allow for humidity, temperature thresholds, and fault status. ```json { "accessory": "mqttthing", "type": "thermostat", "name": "", "url": "", "username": "", "password": "", "topics": { "getCurrentHeatingCoolingState": "", "setTargetHeatingCoolingState": "", "getTargetHeatingCoolingState": "", "getCurrentTemperature": "", "setTargetTemperature": "", "getTargetTemperature": "", "setTemperatureDisplayUnits": "", "getTemperatureDisplayUnits": "", "getCurrentRelativeHumidity": "", "setTargetRelativeHumidity": "", "getTargetRelativeHumidity": "", "setCoolingThresholdTemperature": "", "getCoolingThresholdTemperature": "", "setHeatingThresholdTemperature": "", "getHeatingThresholdTemperature": "", "getStatusFault": "" }, "heatingCoolingStateValues": "", "temperatureDisplayUnitsValues": "", "minTemperature": minimum_target_temperature, "maxTemperature": maximum_taret_temperature, "restrictHeatingCoolingState": "" } ``` -------------------------------- ### Sonoff Tasmota Temperature Sensor Configuration Source: https://github.com/arachnetech/homebridge-mqttthing/wiki/Tested-Configurations Example configuration for Sonoff devices running Tasmota firmware to report temperature. ```json { "accessory": "mqttthing", "type": "temperatureSensor", "name": "YourName", "url": "mqtt://broker's IP", "username": "username", "password": "password", "topics": { "getCurrentTemperature": { "topic": "tele/YourName/SENSOR", "apply": "return JSON.parse(message).DS18B20.Temperature;" } } } ``` -------------------------------- ### Shelly Plus 1 Switch Configuration with Events RPC Source: https://github.com/arachnetech/homebridge-mqttthing/wiki/Tested-Configurations A working example for Shelly Plus 1 using the 'events/rpc' topic for listening, suitable for Homebridge 1.3.8 and mqttthing 1.1.38. Replace bracketed placeholders with your specific values. ```json { "type": "switch", "name": "Doorbell", "url": "", "username": "", "password": "", "topics": { "getOn": { "topic": "/events/rpc", "apply": "return JSON.parse(message).params[\"switch:0\"];" }, "setOn": { "topic": "/rpc", "apply": "return JSON.stringify({id: 123, src: 'user_1', method: 'Switch.Set', params: {id: 0, on: message}});" } }, "manufacturer": "Shelly", "model": "Shelly 1 Plus", "serialNumber": "", "firmwareRevision": "shellyOS", "accessory": "mqttthing" } ``` -------------------------------- ### Codec with Property-Specific Functions Source: https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Codecs.md An example of a codec's 'init' function returning a 'properties' map. This allows defining distinct 'encode' and 'decode' functions for specific accessory properties, falling back to default functions if not specified. ```javascript function init() { return { properties: { targetProp1: { encode: encodeFunction1, decode: decodeFunction1 }, targetProp2: { encode: encodeFunction2 }, }, encode: defaultEncodeFunction, decode: defaultDecodeFunction } } ``` -------------------------------- ### Configure Microphone Accessory Source: https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Accessories.md Set up a microphone accessory to control mute status and volume via MQTT. Topics for getting and setting these states are required. ```json { "accessory": "mqttthing", "type": "microphone", "name": "", "topics": { "getMute": "", "setMute": "", "getVolume": "", "setVolume": "" } } ``` -------------------------------- ### Heater Cooler Accessory Configuration Example Source: https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Accessories.md This JSON configuration defines the MQTT topics and custom values for a Heater Cooler accessory. It allows for control and reporting of active state, heating/cooling states, temperatures, and other features via MQTT. ```json { "accessory": "mqttthing", "type": "heaterCooler", "name": "", "url": "", "username": "", "password": "", "logMqtt": true | false, "topics": { "setActive": "", "getActive": "", "getCurrentHeaterCoolerState": "", "setTargetHeaterCoolerState": "", "getTargetHeaterCoolerState": "", "getCurrentTemperature": "", "setCoolingThresholdTemperature": "", "getCoolingThresholdTemperature": "", "setHeatingThresholdTemperature": "", "getHeatingThresholdTemperature": "", "setTemperatureDisplayUnits": "", "getTemperatureDisplayUnits": "", "setRotationMode": "", "getRotationMode": "", "setSwingMode": "", "getSwingMode": "", "setRotationSpeed": "", "getRotationSpeed": "", "getStatusFault": "" }, "currentHeaterCoolerValues": "", "targetHeaterCoolerValues": "", "lockPhysicalControlsValues": "", "swingModeValues": "", "temperatureDisplayUnitsValues": "", "minTemperature": minimum_target_temperature, "maxTemperature": maximum_target_temperature, "restrictHeaterCoolerState": "" } ``` -------------------------------- ### Xiaomi/Aqara Switch Configuration Source: https://github.com/arachnetech/homebridge-mqttthing/wiki/Tested-Configurations Configuration for Xiaomi/Aqara switches (QBKG24LM/QBKG25LM/QBKG23LM). It sets up topics for getting and setting the switch state, with options for MQTT publishing. ```json { "accessory": "mqttthing", "type": "switch", "name": "Switch Name", "url": "mqtt://:1883", "username": "username", "password": "password", "logMqtt": true, "mqttPubOptions": { "retain": true }, "topics": { "getOn": { "topic": "zigbee2mqtt/ID", "apply": "return JSON.parse(message).state_right === 'ON' ? true : false;" }, "setOn": { "topic": "zigbee2mqtt/ID/set", "apply": "return JSON.stringify({state_right: (message ? \"ON\" : \"OFF\")});" } } } ``` -------------------------------- ### Came ZA3 Door Opener Configuration Source: https://github.com/arachnetech/homebridge-mqttthing/wiki/Tested-Configurations Homebridge MQTT Thing configuration for a Came ZA3 door opener. This setup uses specific 'apply' logic for topic messages. ```json { "accessory": "mqttthing", "name": "ZA3 Door", "type": "garageDoorOpener", "url": "url", "username": "username", "password": "password", "topics": { "getTargetDoorState": { "topic": "shellies/shelly1-C45BBE56XXXX/input/0", "apply": "if (message == 1) { return 'o';} return 'C';" }, "getCurrentDoorState": { "topic": "shellies/shelly1-C45BBE56XXXX/input/0", "apply": "if (message == 1) { return 'O';} return 'C';" }, "setTargetDoorState": { "topic": "shellies/shelly1-C45BBE56XXXX/relay/0/command", "apply": "if (message == 'O') {return 'on'} ; return 'off';" } }, "doorCurrentValues": [ "O", "C", "o", "c", "S" ], "doorTargetValues": [ "O", "C" ], "logMqtt": true } ``` -------------------------------- ### Basic Light Bulb Configuration Source: https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Accessories.md This is a basic configuration for a light bulb accessory. It includes essential topics for getting and setting the on/off state, and optionally for brightness, hue, saturation, and color temperature. ```json { "accessory": "mqttthing", "type": "lightbulb", "name": "", "url": "", "username": "", "password": "", "caption": "