Вклад
21 сентября 2022
Translations:Rule Examples/169/en
Новая страница: «An example of a rule using Schedules: <syntaxhighlight lang="ecmascript"> (function() { // closing»
Translations:Rule Examples/168/en
Новая страница: «})(Schedules); </syntaxhighlight>»
Translations:Rule Examples/166/en
Новая страница: «}; }; };»
Translations:Rule Examples/165/en
Новая страница: «// set schedule dev status as soon as possible at startup (function(schedule) { setTimeout(function() { updateSingleScheduleDevStatus(schedule); }, 1); })(schedule);»
Translations:Rule Examples/164/en
Новая страница: «// if needed, setup periodic task to trigger rules which use this schedule if (schedule.autoUpdate) { addScheduleAutoUpdCronTask(schedule); }»
Translations:Rule Examples/163/en
Новая страница: «// setup cron tasks which updates the schedule dev status at schedule // interval beginings and ends addScheduleDevCronTasks(schedule);»
Translations:Rule Examples/162/en
Новая страница: «for (var schedule_name in _schedules) { if (_schedules.hasOwnProperty(schedule_name)) { var schedule = _schedules[schedule_name];»
Translations:Rule Examples/161/en
Новая страница: «defineVirtualDevice("_schedules", params);»
Rule Examples/en
Новая страница: «for (var schedule_name in _schedules) { if (_schedules.hasOwnProperty(schedule_name)) { var schedule = _schedules[schedule_name]; params.cells[schedule_name] = {type: "switch", value: false, readonly: true}; } };»
−504
Translations:Rule Examples/160/en
Новая страница: «for (var schedule_name in _schedules) { if (_schedules.hasOwnProperty(schedule_name)) { var schedule = _schedules[schedule_name]; params.cells[schedule_name] = {type: "switch", value: false, readonly: true}; } };»
Translations:Rule Examples/159/en
Новая страница: «Schedules.initSchedules = function() { var params = { title: "Schedule Status", cells: {} };»
Translations:Rule Examples/158/en
Новая страница: «Schedules.registerSchedule = function(schedule) { _schedules[schedule.name] = schedule; };»
Translations:Rule Examples/157/en
Новая страница: «var _schedules = {};»
Translations:Rule Examples/156/en
Новая страница: «function addScheduleAutoUpdCronTask(schedule) { defineRule("_schedule_auto_upd_{}".format(schedule.name), { when: cron("@every " + schedule.autoUpdate), then: function() { dev._schedules[schedule.name] = dev._schedules[schedule.name]; } }); }»
Translations:Rule Examples/155/en
Новая страница: «function addScheduleDevCronTasks(schedule) { for (var i = 0; i < schedule.intervals.length; ++i) { var interval = schedule.intervals[i]; for (var j = 0; j < 2; ++j) { // either start or end of the interval var hours = interval[j][0]; var minutes = interval[j][1]; log("cron at " + "0 " + minutes + " " + hours + " * * *"); defineRule("_schedule_dev_{}_{}_{}".format(schedule.name, i, j), { when: cron("0...»
Translations:Rule Examples/154/en
Новая страница: «for (var i = 0; i < schedule.intervals.length; ++i) { var item = schedule.intervals[i]; if (checkScheduleInterval(now, item[0], item[1])) { log("found matching schedule interval at {}".format(item)); return true; } } return false; } function updateSingleScheduleDevStatus(schedule) { log("updateSingleScheduleDevStatus {}".format(schedule.name)); dev["_schedules"][schedule.name] = checkSchedule(schedule)...»
Translations:Rule Examples/153/en
Новая страница: «function checkSchedule(schedule, now) { if (now == undefined) { now = new Date(); }»
Translations:Rule Examples/152/en
Новая страница: «}»
Rule Examples/en
Новая страница: «4. Describe the virtual device in the file»
−336
Translations:Rule Examples/151/en
Новая страница: «if (now >= start_date) { return true; } } return false;»
Translations:Rule Examples/150/en
Новая страница: «// well, that seems not to be the case. ok, // option 2: it's the day of "start" date:»
Translations:Rule Examples/149/en
Новая страница: «// option 1: what if it's now the day of "end" date? // in this case the following is enough: if (now < end_date) { return true; }»
Translations:Rule Examples/148/en
Новая страница: «if (end_date >= start_date) { if ((now >= start_date) && (now < end_date)) { return true; } } else { // end date is less than start date, // assuming they belong to a different days (e.g. today and tomorrow)»
Translations:Rule Examples/147/en
Новая страница: «function checkScheduleInterval(now, start_time, end_time) { var start_date = todayAt(now, start_time[0], start_time[1]); var end_date = todayAt(now, end_time[0], end_time[1]); log("checkScheduleInterval {} {} {}".format(now, start_date, end_date));»
Translations:Rule Examples/146/en
Новая страница: «function todayAt(now, hours, minutes) { var date = new Date(now); // i.e. "today, at HH:MM". All dates are in UTC! date.setHours(hours); date.setMinutes(minutes); return date; }»
Rule Examples/en
Новая страница: «There should be no error messages in the log (exit via control-c)»
−179
Translations:Rule Examples/145/en
Новая страница: «(function(Schedules) { // closing»
Translations:Rule Examples/144/en
Новая страница: «<syntaxhighlight lang="ecmascript"> global.__proto__.Schedules = {};»
Translations:Rule Examples/143/en
Новая страница: «lib_schedules.js:»
Rule Examples/en
Новая страница: «[https://github.com/contactless/wb-rules-system/blob/master/rules/power_status.js Rule] creates a virtual device that reports the current power status. Two ADC channels are used as input data: battery voltage measurement and input voltage measurement.»
−193
Translations:Rule Examples/142/en
Новая страница: «This means that even if the controller is running intermittently and missed the transition time between schedules (10 am), the controller will still turn on the lights at the first opportunity.»
Rule Examples/en
Новая страница: «A few examples of system rules are below.»
−568
Translations:Rule Examples/141/en
Новая страница: «For example, we want the lighting to be on from 10 to 17h. The libschedule will follow the "turn on the lights" rule once a minute from 10 am to 17 PM.»
Translations:Rule Examples/140/en
Новая страница: «Not cron-rules are used for schedules, but the libschedule. The libschedule enables and disables rules, which, unlike cron rules, are executed continuously when enabled.»
Translations:Rule Examples/139/en
Новая страница: «The object is a grocery store. Various store systems are controlled by feedback from temperature sensors and taking into account the store's work schedule.»
Rule Examples/en
Новая страница: «The full contents of the file with the rules:»
−85
Translations:Rule Examples/138/en
Новая страница: «== Complex rules with schedules ==»
Rule Examples/en
Новая страница: «To configure the / dev/ttyNSC0 port to 9600 speed, run the following command»
−348
Translations:Rule Examples/249/en
Новая страница: «When you click Save in the web interface, the wb-rules service will be restarted, and the values of the settings will be written to the rules.»
Translations:Rule Examples/248/en
Новая страница: «service wb-rules restart </syntaxhighlight>»
Translations:Rule Examples/247/en
Новая страница: «<syntaxhighlight lang="bash"> service wb-mqtt-confed restart»
Translations:Rule Examples/246/en
Новая страница: «After creating the files, you need to restart the services»
Rule Examples/en
Новая страница: «A new device "Send custom command to RS-485 port" should appear in the Devices section of the web interface.»
−677
Translations:Rule Examples/245/en
Новая страница: «In the json file describes the schema of the output html page browser, according to generally accepted mapping standard. Description of keys here: json-schema.org ahhh!»
Translations:Rule Examples/244/en
Новая страница: «The last file can also be edited from the web interface on the Scripts tab.»
Translations:Rule Examples/243/en
Новая страница: «log("temperature setpoint is: {}".format(config.temperature_setpoint)); </syntaxhighlight>»
Translations:Rule Examples/242/en
Новая страница: «<syntaxhighlight lang="bash"> var config = readConfig("/etc/test-config.conf");»
Translations:Rule Examples/241/en
Новая страница: «3. Script that updates config : /mnt/data/etc/wb-rules/test-config-script.js»
Translations:Rule Examples/240/en
Новая страница: «2. Description of the default configuration (when saving the form in the web interface, the values will be written to this file) : /etc/test-config.conf <syntaxhighlight lang="bash"> { "temperature_setpoint": 60, "humidity_setpoint": 14 } </syntaxhighlight>»
Translations:Rule Examples/239/en
Новая страница: «"humidity_setpoint": { "type":"number", "title":"Humidity Setpoint (RH, %)", "default": 60, "propertyOrder": 2, "minimum": 10, "maximum": 95 } }, "required": ["temperature_setpoint", "humidity_setpoint"] } </syntaxhighlight>»