Skip to content

Example: Night Light

DerPilz edited this page Sep 21, 2022 · 5 revisions

Example Child Night Light

Problem

I wanted to have a light,

  • that works as normal during the day (the day started at 06:00).
  • starting at 20:00: if someone turns the light on, the light should start from fully turned on down to off in a period of about 30 minutes
  • starting at 22:00: if someone turns the light on, the light should start from fully turned on down to off in a period of about 10 minutes

Assumption

Child Room has a Philips HUE light and the HUE Adapter is installed and configured in ioBroker

image

Solution

In this example there is at least one SawTooth configured with the technical name "zimmerdavid". For SawTooth-Configuration see the documentation in the wiki.

Following Config:

  • MaxValue = 100 (maximum light for HUE)
  • MinValue = 0 (Minimum light, or turned of for HUE)
  • Increment = 0 (disabled, do nothing currently)
  • Readonly = false, because HUE sets the current Value according to the current light configuration

Because HUE has the following behavier:

  • Level = 0 means: Light turned off
  • Level = 100 means: Light fully turned on.

Slow-Mode:

Because the SawTooth adapter incremets once a minute, and the increment has to go down from 100 to 0 in 30 minutes, it has to decrease 3 numbers a step. 3 multiplied with 30 equals round about 100.

Fast-Mode:

If the adapter decreases 10 numbers a step (or a minute), it takes 10 minutes (10 multiplied with 10 equals 100) it takes around 10 minutes to fully decrease

Now the output of the HUE adapter and the SawTooth adapter has to be linked together. I have done this with a blocky-script:

image

The first if block checks, if the hue-level equals to 0. If so, it also sets on to false to really turns the HUE of.

The different speeds and behaviors of the sawtooth-adapter could be done with a time-scheduled adjustment of the increase-parameter:

image

  • At 06:00 ==> increase was set to 0 which means: do nothing
  • At 20:00 ==> increase was set to -3 which means: go down from max to min with decreasing 3 each run.
  • At 22:00 ==> increase was set to -10 which means: go down from max to min with decreasing 10 each run.
Clone this wiki locally