/* * Bugreport script for whenChanged: [FUNC, "DEV/CHANNEL"] * */ defineVirtualDevice( "virt-dev_248", { title: "Test Second input for whenChanged", cells: { sw: { readonly: false, type: "switch", value: false } } }) /* * Проверка передачи двойных встроенных функций * */ function time () { var actualDate = new Date() if (actualDate.getSeconds() % 3 == 0) { return actualDate.getSeconds(); } } log.info(time()); log.info("=== Activate a Rule for 15 seconds"); // Test different options in whenChanged var testRule = defineRule("test func and parameter", { // OK: switch toggle trigger whenChanged // whenChanged: ["virt-dev_248/sw"], // OK: time() triggers whenChanged) // whenChanged: function () { return time(); }, // FAILED: time() doesn't trigger whenChanged // whenChanged: ["virt-dev_248/sw", function () { return time(); }], whenChanged: [function () { return time(); }, "virt-dev_248/sw"], then: function (newValue, devName, cellName) { log.info("Rule execution..."); log.info(time()); } }); setTimeout(function () { log.info("=== Disable the Rule"); disableRule(testRule); }, 15 * 1000);