Simulates presence by playing back Item states from the default persistence from a number of days ago commanding the devices so they behave the same way, simulating presence.
Parameter
Type
Purpose
Enable Simulation
Switch Item
Switch Item which, when OFF, will trigger the simulator rule to run. OFF was chosen to make it easier to tie the rule to an Item that tracks presence.
Simulation Items Group
Group Item
Group whose members are those Items that should be included in the presence simulation. All these Items must support commands (e.g. no Contact Items) and their states must be saved by the default persistence (e.g. no String Items if using rrd4j).
Num Days
integer
The number of days in the past to simulate the behavior from. It’s best to choose a multiple of 7 to correctly capture different behaviors between work days and weekends.
Minutes
integer
How many minutes between runs of the rule.
This template is a rewrite of the version written for 3.x to take advantage of new features built into OH 4 and to use JS Scripting.
Language: JS Scripting Scripting with openhab-js 4.0
Dependencies:
Persistence is installed and configured and the default persistence saves the states of the Items that are to be simulated.
openhab-js 4.1.0 or later
openhab_rules_tools 2.0.1 or later
Changelog
Version 0.2
throws an exception if openhab-js or openhab_rules_tools is too old
Open a new thread to go over what ever the problem is with installing the marketplace. Fixing that is outside the scope of this thread and I have no idea what the problem can be.
I use OH 4.0.2 and just see this rule template to install when I enable unpublished Add-Ons in Community Marketplace Add-Ons. And then I get a warning if I really want to install.
Is it safe to install and use? Installed openhab-js version is 4.0.2
You should be seeing commands and where applicable changes in events.log.
There is very little logging in the rule itself. There’s a debug if the rule decides not to command the Item if it’s already in the desired state and a warning level log if there is no data in persistence to play back.
You can change the logging level of the rule in all the usual ways or by editing the Script Action to change line 4 and uncommenting it out. You can also add additional log statements or make any other changes desired.
I just did found out in openhab.log, that I get this error when to rule tries to start.
2023-09-16 17:55:00.292 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘cc3bac37a8’ failed: org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (getMembers) on org.openhab.core.library.items.SwitchItem@183530b failed due to: Unknown identifier: getMembers
2023-09-16 18:00:00.277 [ERROR] [b.automation.script.javascript.stack] - Failed to execute script:
org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (getMembers) on org.openhab.core.library.items.SwitchItem@183530b failed due to: Unknown identifier: getMembers
at .get members(@openhab-globals.js:2) ~[?:?]