Hello, have you thought or have in plan to create a Govee plugin. There devices are becoming more and more popular and have many devices that compete with HUE.
Thanks!
Hello, have you thought or have in plan to create a Govee plugin. There devices are becoming more and more popular and have many devices that compete with HUE.
Thanks!
There is one… I wrote it
plugin.Name = “Govee”;
plugin.OnChangeRequest = onChangeRequest;
plugin.OnConnect = onConnect;
plugin.OnDisconnect = onDisconnect;
plugin.OnPoll = onPoll;
plugin.OnSynchronizeDevices = onSynchronizeDevices;
plugin.PollingInterval = 8000;
plugin.DefaultSettings = {};
var http = new HTTPClient();
//settings
//var plugindevice = plugin.Devices[1];
//var api = (plugin.Settings[“api”])
//var devicedetails = (plugin.Settings[“devicedetails”])
//var model = (plugin.Settings[“model”])
//globalvariables
var controlurl = “https://developer-api.govee.com/v1/devices/control”
var queryurl = “https://developer-api.govee.com/v1/devices/”
var queryurl1 = “https://developer-api.govee.com/v1/devices/state?device=” + encodeURIComponent(plugin.Settings[“devicedetails”]) + “&model=” + (plugin.Settings[“model”])
function onChangeRequest(device, attribute, value) {
switch (attribute) {
case “Switch”:
switch(value) {
case “On”:
console.log(“switching on”)
var options = { headers: {“Govee-API-Key”: (plugin.Settings[“api”])}}
var cmd = {“device”: (plugin.Settings[“devicedetails”]),“model”: (plugin.Settings[“model”]),“cmd”: {“name”: “turn”, “value”: “on”}}
http.put(controlurl, cmd, options)
break;
case “Off”:
console.log(“switching off”)
var options = { headers: {“Govee-API-Key”: (plugin.Settings[“api”])}}
var cmd = {“device”: (plugin.Settings[“devicedetails”]),“model”: (plugin.Settings[“model”]),“cmd”: {“name”: “turn”, “value”: “off”}}
http.put(controlurl, cmd, options)
}
case “Colour”:
switch(value){
case “Green”:
var options = { headers: {“Govee-API-Key”: (plugin.Settings[“api”])}}
var cmd = {“device”: (plugin.Settings[“devicedetails”]),“model”: (plugin.Settings[“model”]),“cmd”: {“name”: “color”,“value”: {“r”: 0,“g”: 255,“b”: 0}}}
http.put(controlurl, cmd, options)
break;
case “Blue”:
var options = { headers: {“Govee-API-Key”: (plugin.Settings[“api”])}}
var cmd = {“device”: (plugin.Settings[“devicedetails”]),“model”: (plugin.Settings[“model”]),“cmd”: {“name”: “color”,“value”: {“r”: 0,“g”: 0,“b”: 255}}}
http.put(controlurl, cmd, options)
break;
case “Red”:
var options = { headers: {“Govee-API-Key”: (plugin.Settings[“api”])}}
var cmd = {“device”: (plugin.Settings[“devicedetails”]),“model”: (plugin.Settings[“model”]),“cmd”: {“name”: “color”,“value”: {“r”: 255,“g”: 0,“b”: 0}}}
http.put(controlurl, cmd, options)
break;
case “White”:
var options = { headers: {“Govee-API-Key”: (plugin.Settings[“api”])}}
var cmd = {“device”: (plugin.Settings[“devicedetails”]),“model”: (plugin.Settings[“model”]),“cmd”: {“name”: “color”,“value”: {“r”: 255,“g”: 255,“b”: 255}}}
http.put(controlurl, cmd, options)
}
}
switch (attribute) {
case “Brightness”:
var options = { headers: {“Govee-API-Key”: (plugin.Settings[“api”])}}
var cmd = {“device”: (plugin.Settings[“devicedetails”]),“model”: (plugin.Settings[“model”]),“cmd”: {“name”: “brightness”,“value”: value}}
http.put(controlurl, cmd, options)
break;
case “Temperature”:
var options = { headers: {“Govee-API-Key”: (plugin.Settings[“api”])}}
var cmd = {“device”: (plugin.Settings[“devicedetails”]),“model”: (plugin.Settings[“model”]),“cmd”: {“name”: “colorTem”,“value”: value}}
http.put(controlurl, cmd, options)
break;
case “Color”:
device.Color = value
hex = (value.toString()) //convert to string
hex1 = hex.substring(1) // remove #
var aRgbHex = hex1.match(/.{1,2}/g) // use regex to split 3 channels
var aRgb = [parseInt(aRgbHex[0], 16), parseInt(aRgbHex[1], 16), parseInt(aRgbHex[2], 16)] //create array with 3 RGB values
var options = { headers: {"Govee-API-Key": (plugin.Settings["api"])}}
var cmd = {"device": (plugin.Settings["devicedetails"]),"model": (plugin.Settings["model"]),"cmd": {"name": "color","value": {"r": aRgb[0],"g": aRgb[1],"b": aRgb[2]}}}
http.put(controlurl, cmd, options)
}
}
function onConnect() {
}
function onDisconnect() {
}
function onPoll() {
var plugindevice = plugin.Devices[1];
var options = { headers: {'Govee-API-Key': (plugin.Settings["api"]) }}
var result = http.get(queryurl1, options)
var queryresult = result.data
plugindevice.Brightness = (queryresult.data.properties[2].brightness)
console.log(queryresult.data.properties[1].powerState)
switch (queryresult.data.properties[1].powerState) {
case "on":
plugindevice.Switch = "On"
break;
case "off":
plugindevice.Switch = "Off"
}
if(plugindevice.Switch == "Off"){
plugindevice.Color = "#00FFFFFF"
}
}
function onSynchronizeDevices() {
var virtualSwitch = new Device();
virtualSwitch.Id = “1”;
virtualSwitch.DisplayName = “Virtual Switch”;
virtualSwitch.Capabilities = [“Switch”];
virtualSwitch.Attributes = [];
plugin.Devices[virtualSwitch.Id] = virtualSwitch;
}