2482
правки
Admin (обсуждение | вклад) |
Admin (обсуждение | вклад) |
||
Строка 44: | Строка 44: | ||
=== Первое правило с виртуальным устройством === | === Первое правило с виртуальным устройством === | ||
Создаём виртуальный переключатель, при нажатии на который переключаются сразу два реле. | |||
<syntaxhighlight lang="ecmascript"> | <syntaxhighlight lang="ecmascript"> | ||
defineVirtualDevice(" | defineVirtualDevice("switch_both", { | ||
title: " | title: "Switch both relays", | ||
cells: { | cells: { | ||
enabled: { | enabled: { | ||
Строка 57: | Строка 57: | ||
}); | }); | ||
defineRule("control_both", { | |||
defineRule(" | whenChanged: "switch_both/enabled", | ||
whenChanged: " | then: function (newValue, devName, cellName) { | ||
then: function (newValue, devName, cellName) { | dev["wb-mrm2_130"]["Relay 1"] = newValue; | ||
dev["wb- | dev["wb-mrm2_130"]["Relay 2"] = newValue; | ||
} | } | ||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||