I am looking to generate a contant for each room in a synthetic sensor lux.roomname … with a value of "Pitch Black, Dark, Dim, Light, Bright’ for each room by evaulating the lux value from sensors I have in each of 12 rooms.’ Then I could check to see what is a room a Dim to set early evening or morning lighting, etc.
Are the thresholds for each value the same for all 12 rooms?
For example, if “Dim” is between 80 and 50 in the bedroom, does “Dim” in the kitchen use the same threshold of 80 and 50? Or are the thresholds likely to be unique for each room?
EDIT
To help you get started, create a Template Sensor helper via:
Settings → Device & Services → Helpers
Create Helper → Template → Template a sensor
Give it a name and enter the following Jinja2 template into the State template field:
The 0 in int(0) represents the default value (you choose what you want the value to be). If the supplied value cannot be converted to an integer, 0 will be the result.
If you overlook to supply int() with a default value, if will produce an error message if it is unable to convert the supplied value to an integer (i.e. the template fails and terminates further processing).
The template defines a dictionary (key-value pairs). The template is designed to produce keys that are boolean values (true/false). If the value of lux is within a specific range, that key will be true. The template is designed so that only one key can be true.
get is one of the methods of a dictionary. In this specific example, it attempts to get the value of whichever key is true. If none of the keys is true, get reports its default value (I chose unknown as the default).
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.