Вклад
21 сентября 2022
Translations:Rule Examples/238/en
Новая страница: «"properties": { "temperature_setpoint": { "type":"number", "title":"Temperature Setpoint (Degrees C)", "default": 25, "propertyOrder": 1, "minimum": 5, "maximum": 40 },»
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"] ; } } });»
−565
Translations:Rule Examples/237/en
Новая страница: «"configFile": { "path":"/etc/test-config.conf", "service":"wb-rules" },»
Translations:Rule Examples/236/en
Новая страница: «1. The output scheme of the html page in the Configs section: /usr/share/wb-mqtt-confed/schemas/test-config.schema.json <syntaxhighlight lang="bash"> { "type":"object", "title":"Test configuration", "description":"Long description configuration",»
Translations:Rule Examples/235/en
Новая страница: «Three files are required:»
Translations:Rule Examples/234/en
Новая страница: «The correct but tricky way is to create a new tab in the Configs section with editable settings options fields.»
Translations:Rule Examples/3/en
Новая страница: «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. But a complex setup with menus and options cannot be done this way.»
Rule Examples/en
Новая страница: «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"); } });»
−238
Translations:Rule Examples/233/en
Новая страница: «300px|thumb|right|Example configuration 300px|thumb|right|Example script If you need to manually enter temperature and humidity settings in the interface of the Wiren Board controller.»
Translations:Rule Examples/135/en
Новая страница: «== Custom fields in web interface ==»
Rule Examples/en
Новая страница: «2. Sending a command»
−237
Translations:Rule Examples/232/en
Новая страница: «trackMqtt("/devices/+/controls/+/meta/error", function(message){ log.info("name: {}, value: {}".format(message.topic, message.value)) if (message.value=="r"){ dev["meta_error_test/topic"] = message.topic; dev["meta_error_test/value"] = message.value; } }); </syntaxhighlight>»
Translations:Rule Examples/231/en
Новая страница: «<syntaxhighlight lang="ecmascript"> defineVirtualDevice("meta_error_test", { title: "Metaerordisplay", cells: { topic: { type: "text", value: "", readonly: true }, value: { type: "text", value: "", readonly: true }, } });»
Translations:Rule Examples/230/en
Новая страница: «== Handling errors when working with serial devices == Implemented by subscribing to all '''meta/error''' topics.»
Rule Examples/en
Новая страница: «<syntaxhighlight lang="ecmascript"> 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"); } });»
−177
Translations:Rule Examples/229/en
Новая страница: «runShellCommand(command); </syntaxhighlight>»
Translations:Rule Examples/228/en
Новая страница: «<syntaxhighlight lang="ecmascript"> varmessage = "Text"; // write your message text var token = "TOKEN"; // replace with bot token var chat_id = CHATID; // replace with your chat_id var command = 'curl -s -X POST https://api.telegram.org/bot{}/sendMessage -d chat_id={} -d text="{}"'.format(token, chat_id, message);»
Rule Examples/en
Новая страница: «defineRule("_rs485_switch_off", { asSoonAs: function () { return !dev.rs485_cmd.enabled; }, then: function() { runShellCommand("/usr/bin/printf '\\xff\\xff\\x0a\\x01\\x00\\x00\\x00\\x0b' >/dev/ttyNSC0"); } });»
−705
Translations:Rule Examples/227/en
Новая страница: «== Sending a message via Telegram bot == {{Anchor|telegram}} Messages are sent using [https://core.telegram.org/api#telegram-api Telegram API] via <code>curl</code>.»
Translations:Rule Examples/134/en
Новая страница: «</syntaxhighlight>»
Translations:Rule Examples/133/en
Новая страница: «setTimeout(setup_port, 1000); // set setup_port() running 1 second after starting.»
Translations:Rule Examples/132/en
Новая страница: «defineRule("_rs485_switch_off", { asSoonAs: function () { return !dev.rs485_cmd.enabled; }, then: function() { runShellCommand("/usr/bin/printf '\\xff\\xff\\x0a\\x01\\x00\\x00\\x00\\x0b' >/dev/ttyNSC0"); } });»
Translations:Rule Examples/131/en
Новая страница: «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"); } });»
Translations:Rule Examples/130/en
Новая страница: «function setup_port() { runShellCommand("stty -F /dev/ttyNSC0 ospeed 9600 ispeed 9600 raw clocal -crtscts -parenb -echo cs8"); }»
Translations:Rule Examples/129/en
Новая страница: «<syntaxhighlight lang="ecmascript"> defineVirtualDevice("rs485_cmd", { title: "Send custom command to RS-485 port", cells: { enabled: { type: "switch", value: false }, } });»
Translations:Rule Examples/128/en
Новая страница: «The full contents of the file with the rules:»
Translations:Rule Examples/127/en
Новая страница: «7. Putting it all together»
Rule Examples/en
Новая страница: «cells: { 'working on battery' : { type : "switch", value : false, readonly : true }, 'Vin' : { type : "voltage", value : 0 }»
−279
Translations:Rule Examples/126/en
Новая страница: «Note the double shielding.»
Translations:Rule Examples/125/en
Новая страница: «</syntaxhighlight>»
Translations:Rule Examples/124/en
Новая страница: «defineRule("_rs485_switch_off", { asSoonAs: function () { return !dev.rs485_cmd.enabled; }, then: function() { runShellCommand("/usr/bin/printf '\\xff\\xff\\x0a\\x01\\x00\\x00\\x00\\x0b' >/dev/ttyNSC0"); } });»
Translations:Rule Examples/123/en
Новая страница: «<syntaxhighlight lang="ecmascript"> 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"); } });»
Rule Examples/en
Новая страница: «Many of the indications that are visible in the web interface of the controller out of the box are also created by rules on the wb-rules engine. Their code is here: [https://github.com/wirenboard/wb-rules-system https://github.com/wirenboard/wb-rules-system]. The system rules are collected in the <code>wb-rules-system</code> package, the script files on the controller are located in the <code>/usr/share/wb-rules-system/</code> folder.<code></code>»
−100
Translations:Rule Examples/122/en
Новая страница: «7. Let's describe the rules for turning the switch on and off»
Rule Examples/en
Новая страница: «defineRule("_system_buzzer_onof", { whenChanged: "buzzer/enabled", then: function (newValue, devName, cellName) { if ( dev.buzzer.enabled) { _buzzer_set_params(); runShellCommand("echo 1 > /sys/class/pwm/pwmchip0/pwm2/enable"); } else { runShellCommand("echo 0 > /sys/class/pwm/pwmchip0/pwm2/enable"); } } });»
−318
Translations:Rule Examples/121/en
Новая страница: «</syntaxhighlight>»
Translations:Rule Examples/120/en
Новая страница: «<syntaxhighlight lang="ecmascript"> function setup_port() { runShellCommand("stty -F /dev/ttyNSC0 ospeed 9600 ispeed 9600 raw clocal -crtscts -parenb -echo cs8"); }»
Translations:Rule Examples/119/en
Новая страница: «6. Add a function to configure the port.»
Translations:Rule Examples/118/en
Новая страница: «A new device "Send custom command to RS-485 port" should appear in the Devices section of the web interface.»
Rule Examples/en
Новая страница: «<pre> /usr/bin/printf '\xFF\xFF\x0A\x01\xD1\x06\x00\xE2' >/dev/ttyNSC0 </pre> where "\xFF\xFF\x0A\x01\xD1\x06\x00\xE2" - is the entry of a "FF FF 0A 01 D1 06 00 E2" command.»
−383
Translations:Rule Examples/117/en
Новая страница: «There should be no error messages in the log (exit via control-c)»
Translations:Rule Examples/116/en
Новая страница: «<pre> root@wirenboard:~# /etc/init.d/wb-rules restart root@wirenboard:~# tail -f /var/log/messages </pre>»
Translations:Rule Examples/115/en
Новая страница: «5. Restart wb-rules and check the operation»
Translations:Rule Examples/114/en
Новая страница: «<syntaxhighlight lang="ecmascript"> defineVirtualDevice("rs485_cmd", { title: "Send custom command to RS-485 port", cells: { enabled: { type: "switch", value: false }, } }); </syntaxhighlight>»
Translations:Rule Examples/113/en
Новая страница: «4. Describe the virtual device in the file»
Rule Examples/en
Новая страница: «When you turn on the switch a command will be sent: (Set Brightness ch. 00=0xff) for Uniel UCH-M141: <pre> FF FF 0A 01 FF 00 00 0A </pre>»
−686
Translations:Rule Examples/112/en
Новая страница: «<pre> root@wirenboard:~# mcedit /etc/wb-rules/rs485_cmd.js </pre>»
Translations:Rule Examples/111/en
Новая страница: «The file can be edited with vim, nano, or mcedit in an ssh session on the device, or it can be downloaded with SCP.»
Translations:Rule Examples/110/en
Новая страница: «3. Create the new rules file <code>/etc/wb-rules/rs485_cmd.js</code> in the rules engine»
Translations:Rule Examples/109/en
Новая страница: «<pre> /usr/bin/printf '\xFF\xFF\x0A\x01\xD1\x06\x00\xE2' >/dev/ttyNSC0 </pre> where "\xFF\xFF\x0A\x01\xD1\x06\x00\xE2" - is the entry of a "FF FF 0A 01 D1 06 00 E2" command.»