This rule template works as a virtual light sensor, providing a software only approximation of a hardware outside light sensor.
It takes total sun radiation, as provided by the Astro binding, and corrects it for clouds with data provided by the by the Synop Analyzer binding or a weather binding. The resulting light intensity value in Lux updates an item that can be used to trigger outside light level dependent behaviour in other rules.
Language: javascript (ECMAScript 5.1 Nashorn)
A version for OH 4.0 for the JavaScript Scripting Add-on (ECMAScript 2022+ ES6) is available here
Dependencies
- Total Radiation item: item representing total sun radiation in a location, as provided by the Astro binding.
- Cloudiness item: item representing cloudiness. This can be an okta value as provided by the Synop Analyzer binding or a cloudiness percentage as provided by a weather binding.
Configuration
The rule template needs to be configured with 2 input and 1 or 2 output items.
Input:
- Total Radiation: name of the item (Number) that represents the total (sum of direct and diffuse) sun radiation.
- Cloudiness: name of the item (Number) that represents to okta value or cloudiness percentage. The okta value is a value between 0 and 8 (integer values) representing the level of cloudiness, with 0 a clear sky.
- Percent: flag indicating if the cloudiness input is an okta value (percent = false), or a cloudiness percentage value (percent = true).
Output:
- Lux: name of item (Number:Illuminance) that represents the total sun radiation in Lux without considering the cloud layer.
- Weighted Lux: name of item (Number:Illuminance) that represents the sun radiation in Lux, considering the effect of the cloud layer.
One of the output items can be omitted if not relevant for your use case.
Changelog
Version 0.7
- Use event data for items
Version 0.6
- Fix for UNDEF inputs
Version 0.5
- Added support for cloudiness percentage from weather bindings
- Treat UNDEF inputs
Version 0.4
- Converted to javascript and rule template
Version 0.3
- Converted to jython
Version 0.2
- DSL rule modified to use Okta from Synop Analyzer binding and Total Radiation from Astro binding
Version 0.1
- Initial release of DSL rule, based on Domoticz LUA script at Lua dzVents - Solar Data: Azimuth Altitude Lux - Domoticz (by Sebastien Joly, Neutrino, Jmleglise)
Resources
A wider discussion and history can be found in the community thread.