It is a narrow matter to automate the light in the bathroom, with the help of e.g. a motion sensor. Enter the bathroom and the light will be turned on. X-minutes after there is no movement, then turn off the light. It is basic lighting control with a motion sensor. But what is no more annoying than standing in the shower or sitting in a hot bath and the light turns off?
Well – there is a simple solution for this too. At home, we have introduced SPA mode in the bathroom. That is, when someone is going to take a good hot bath, we only turn on the SPA mode. We activate this by using a remote control for the purpose.
When the SPA mode is activated, the light will not go out until we deactivate the SPA mode.
To make sure that the light is not turned off, we have added a counter. If the counter is more than 0, then the motion sensor automation will not be performed. If the counter is 0, then the automation will be performed and the light will be turned off after x-minutes without movement.
To be able to add a counter, we need to add a few extra lines in the configuration.yaml file:
counter:
spa:
restore: true
step: 1
These four lines do the following:
counter <- specifies that we should create a counter.
spa <- the name of the counter. In Home Assistant, this then becomes counter.spa
restore: true <- if HA boots, then you will keep the value on the counter
step: 1 <- how much should the counter increase/decrease for each time
You can read more about the counter in Home Assistant here
So in the automation for the SPA mode, we must then choose that we increase the SPA counter by +1 when it is activated. This is done by entering an activity that runs the service “counter.increment”.
Then the counter increases by 1 as we described earlier in the configuration file.
When the SPA activity is to end, we must run the service “counter.reset” – then we reset the counter, and the automation for normal lighting control will start working again.