Skip to content
This repository was archived by the owner on Apr 8, 2019. It is now read-only.

How it works Usage

Guy Verschuere edited this page Aug 12, 2017 · 4 revisions

Because script_device_pass2php.lua is a basic Domoticz event script it get's triggered upon every device update. Result is that for each device update the pass2php.php script is called.
The LUA script sends the name and status of the updated device to pass2php.php.
In pass2php this data is stored in apcu-cache for all devices with a file in the pass2php folder that has exactly the same name as the changed device. So if you want to do something with a device called 'PIRhall' you need to create a file pass2php/PIRhall.php. Keep in mind that everything is case sensitive.
If you only need the status but no action when that device is changed a empty file is good enough.
After the device script is executed a series of cron files are executed, if their timeout is already expired. In __cron604800.PHP there's a part cron604800 that grabs all used devices from domoticz. Their current state, idx and timestamp is stored in apcu cache.
Once the cache is filled it receives it's updates by the pass2php script so everything is in sync.
All information is stored based on the name of the device, starting with a s for state, i for idx or t for timestamp.

if(apcu_fetch('sPIRhall')=='Off'&&apcu_fetch('tPIRhall')<time-120))sw('lighthall','Off');

See the pass2php folder for many examples.

Clone this wiki locally