Rule Examples/en: различия между версиями

Новая страница: «defineRule("_system_track_vin", { whenChanged: "wb-adc/Vin", then: function() { if (dev["wb-adc"]["Vin"] < dev["wb-adc"]["BAT"] ) { dev["power_status"]["Vin"] = 0; } else { dev["power_status"]["Vin"] = dev["wb-adc"]["Vin"] ; } } });»
(Новая страница: «defineRule("_rs485_switch_on", { asSoonAs: function () { return dev.rs485_cmd.enabled; }, then: function() { runShellCommand("/usr/bin/printf '\\xff\\xff\\x0a\\x01\\xff\\x00\\x00\\x0a' > /dev/ttyNSC0"); } });»)
(Новая страница: «defineRule("_system_track_vin", { whenChanged: "wb-adc/Vin", then: function() { if (dev["wb-adc"]["Vin"] < dev["wb-adc"]["BAT"] ) { dev["power_status"]["Vin"] = 0; } else { dev["power_status"]["Vin"] = dev["wb-adc"]["Vin"] ; } } });»)
Строка 851: Строка 851:
If you need to manually enter temperature and humidity settings in the interface of the Wiren Board controller.  
If you need to manually enter temperature and humidity settings in the interface of the Wiren Board controller.  


<div lang="ru" dir="ltr" class="mw-content-ltr">
An easy way is to do in the defineVirtualDevice() field, make it readonly: false. And it will appear in the web interface in Devices as editable, and the value will be saved in the rules engine.
Простой способ, это сделать в defineVirtualDevice() поле, ему сделать readonly: false. И оно появится в веб-интерфейсе в Devices как редактируемое, а значение будет сохраняться в движке правил.
But a complex setup with menus and options cannot be done this way.
Но сложную настройку с меню и вариантами так не сделать.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
The correct but tricky way is to create a new tab in the Configs section with editable settings options fields.
Правильный, но сложный способ — создать новую вкладку в разделе Configs с редактируемыми полями параметров установок .
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
Three files are required:
Потребуются три файла:
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
1. The output scheme of the html page in the Configs  
1. Схема вывода html странички в разделе Configs : /usr/share/wb-mqtt-confed/schemas/test-config.schema.json
section: /usr/share/wb-mqtt-confed/schemas/test-config.schema.json
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
{
{
Строка 871: Строка 865:
"title":"Test configuration",
"title":"Test configuration",
"description":"Long description configuration",
"description":"Long description configuration",
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
"configFile": {
"configFile": {
"path":"/etc/test-config.conf",
"path":"/etc/test-config.conf",
"service":"wb-rules"
"service":"wb-rules"
},
},
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
<div lang="ru" dir="ltr" class="mw-content-ltr">
translator, wb_editors
4293

правки