cflurin / homebridge-mqtt

Homebridge-mqtt is a Plugin for Homebridge.
Apache License 2.0
229 stars 39 forks source link

using MQTT with HomeBrige for RGB #3

Closed diasrobson closed 7 years ago

diasrobson commented 8 years ago

How can i use this with Home Kit / Home bridge to controll RGB lights

cflurin commented 8 years ago

HomeKit doesn't support RGB. However you can define a Lightbulb with the optional characteristics:

{
    "name":"office_lamp",
    "service":"Lightbulb", 
    "Brightness": "default",
    "Hue": "default",
    "Saturation": "default"
};

You'll get 3 mqtt messages:

{ "name": "office_lamp", "characteristic": "Hue", "value": 157 }
{ "name": "office_lamp", "characteristic": "Saturation", "value": 36 }
{ "name": "office_lamp", "characteristic": "Brightness", "value": 28 }

These values can be used to convert HSV to RGB.

In https://github.com/cflurin/homebridge-mqtt/blob/master/lib/utils.js

you'll find the functions hsv2rgb and rgb2hsv. Just copy the code in your app.