для zigbee - через publish^ https://wirenboard.com/wiki/ZigBee_Support#.D0.A3.D0.BF.D1.80.D0.B0.D0.B2.D0.BB.D0.B5.D0.BD.D0.B8.D0.B5_.D1.83.D1.81.D1.82.D1.80.D0.BE.D0.B9.D1.81.D1.82.D0.B2.D0.B0.D0.BC.D0.B8
defineRule(“Ворота”, {
whenChanged: “VorotaOnOff”,
then: function(newValue, devName, cellName) {
if (newValue) {
publish(“zigbee2mqtt/0x842e14fffee3858a/set”, JSON.stringify({ state: “ON” }), 2, false);
setInterval(function offrelay() {
publish(“zigbee2mqtt/0x842e14fffee3858a/set”, JSON.stringify({ state: “OFF” }), 2, false);
}, 400);
}
}
});
я наверное не правильно понял
defineRule("Ворота", {
whenChanged: "VorotaOnOff",
then: function(newValue, devName, cellName) {
if (newValue) {
publish("/zigbee2mqtt/0x842e14fffee3858a/set", JSON.stringify({ state: "ON" }), 2, false);
setInterval(function offrelay() {
publish("/zigbee2mqtt/0x842e14fffee3858a/set", JSON.stringify({ state: "OFF" }), 2, false);
}, 400);
}
}
});
title: "VorotaOnOff",
cells: {
"pushbutton": {
type: "pushbutton",
value: 0,
}
}
});
defineRule("Ворота", {
whenChanged: "VorotaOnOff",
then: function(newValue, devName, cellName) {
if (newValue) {
publish("/zigbee2mqtt/0x842e14fffee3858a/set", JSON.stringify({ state: "ON" }), 2, false);
setInterval(function offrelay() {
publish("/zigbee2mqtt/0x842e14fffee3858a/set", JSON.stringify({ state: "OFF" }), 2, false);
}, 400);
}
}
});
Отредактировал.
defineVirtualDevice("VorotaOnOff", {
title: "VorotaOnOff",
cells: {
pushbutton: {
type: "pushbutton",
value: 0,
}
}
});
defineRule("Ворота", {
whenChanged: "VorotaOnOff/pushbutton",
then: function(newValue, devName, cellName) {
if (newValue) {
publish("/zigbee2mqtt/0x842e14fffee3858a/set", JSON.stringify({ state: "ON" }), 2, false);
setTimeout(function offrelay() {
publish("/zigbee2mqtt/0x842e14fffee3858a/set", JSON.stringify({ state: "OFF" }), 2, false);
}, 400);
}
}
});
Ну синтаксис же…
Не, так и не заработало…
Ну судя по
payload_off: "OFF"
payload_on: "ON"
value_template: "{{ value_json.state }}"
command_topic: "zigbee2mqtt/<FRIENDLY_NAME>/set"
из статьи - делаем правильно…
title: "VorotaOnOff",
cells: {
pushbutton: {
type: "pushbutton",
value: 0,
}
}
});
defineRule("Ворота", {
whenChanged: "VorotaOnOff/pushbutton",
then: function(newValue, devName, cellName) {
if (newValue) {
publish("zigbee2mqtt/0x842e14fffee3858a/set", JSON.stringify({ state: "ON" }), 2, false);
setTimeout(function offrelay() {
publish("zigbee2mqtt/0x842e14fffee3858a/set", JSON.stringify({ state: "OFF" }), 2, false);
}, 200);
}
}
});
Поправил, все работает
1 лайк