Может кому пригодиться. Накидал правило (драйвер MQTT) для ShellyUNI
ShellyUNI MQTT
// MQTT driever ShellyUNI
var deviceName = "ShellyUNI";
var deviceAddr = "AABBCCDDEEFF";
defineVirtualDevice(deviceName, {
title: deviceName,
cells: {
"input0": {
type: "switch",
value: false,
readonly: true
},
"input1": {
type: "switch",
value: false,
readonly: true
},
"inputCnt0": {
type: "value",
value: 0,
readonly: true
},
"inputCnt1": {
type: "value",
value: 0,
readonly: true
},
"relay0": {
type: "switch",
value: false
},
"relay1": {
type: "switch",
value: false
},
"adc": {
type: "voltage",
value: 0,
readonly: true
}
}
});
defineRule("relay0_change", {
whenChanged: deviceName+"/relay0",
then: function (newValue, devName, cellName) {
var state = (newValue == true) ? "on" : "off";
publish("shellies/shellyuni-"+deviceAddr+"/relay/0/command", state);
}
});
defineRule("relay1_change", {
whenChanged: deviceName+"/relay1",
then: function (newValue, devName, cellName) {
var state = (newValue == true) ? "on" : "off";
publish("shellies/shellyuni-"+deviceAddr+"/relay/1/command", state);
}
});
trackMqtt("shellies/shellyuni-"+deviceAddr+"/input_event/0", function(message){
var obj = JSON.parse(message.value);
dev[deviceName+"/inputCnt0"] = parseInt(obj.event_cnt);
});
trackMqtt("shellies/shellyuni-"+deviceAddr+"/input_event/1", function(message){
var obj = JSON.parse(message.value);
dev[deviceName+"/inputCnt1"] = parseInt(obj.event_cnt);
});
trackMqtt("shellies/shellyuni-"+deviceAddr+"/input/0", function(message){ dev[deviceName+"/input0"] = (message.value == "1") ? true : false; });
trackMqtt("shellies/shellyuni-"+deviceAddr+"/input/1", function(message){ dev[deviceName+"/input1"] = (message.value == "1") ? true : false; });
trackMqtt("shellies/shellyuni-"+deviceAddr+"/relay/0", function(message){ dev[deviceName+"/relay0"] = (message.value == "on") ? true : false; });
trackMqtt("shellies/shellyuni-"+deviceAddr+"/relay/1", function(message){ dev[deviceName+"/relay1"] = (message.value == "on") ? true : false; });
trackMqtt("shellies/shellyuni-"+deviceAddr+"/adc/0", function(message){ dev[deviceName+"/adc"] = parseFloat(message.value) });