Bedside lamp button

2020-04-10

My bedside lamp works pretty well, but it can be frustrating to use sometimes. Depending on the time of day or night, I often need to turn on the ceiling light to avoid stumbling around the bedroom, and then swap to the bedside lamp before I go to bed. In addition, it's difficult to keep the lamp at a sensible brightness, depending on how well my eyes have adjusted to the light. Smart globes make this easier, but opening up Home Assistant on my phone just to control the brightness is a hassle.

A bedside lamp illuminated to 5%, with a hand holding a Zigbee button in front of it.
The bedside lamp and accompanying button

The bedside lamp button solves these issues:

  • The button is portable, and with a magnet mounted on the back, can be attached to the wall near the door frame and carried to bed.
  • The button supports single-click and double-click actions, so a single-click can toggle the lamp on and off, while a double-click can switch the brightness between dimmest and brightest.

Devices

Home Assistant configuration

The automations process the following scenarios:

  1. When a message comes through with a " single" click, run the " light.toggle" service for the light bulb.
  2. When a message comes through with a " double" click, run the " light.on" service for the light bulb with a preset "brightness" value. Make it bright (255) if it is currently dim (5), otherwise make it dim (5).
$ cat /home/homeassistant/.homeassistant/automations.yaml
    
...
- id: toggle_bedside_lamp
  alias: Toggle bedside lamp
  trigger:
  - entity_id: sensor.0x00158d00033e8df9_click
    platform: state
    to: single
  action:
  - service: light.turn_on
    data:
      entity_id: light.0xb0ce1814033b6827_light

- id: set_bedside_lamp_brightness
  alias: Set bedside lamp brightness
  trigger:
  - entity_id: sensor.0x00158d00033e8df9_click
    platform: state
    to: double
  action:
  - service: light.turn_on
    data_template:
      entity_id: light.0xb0ce1814033b6827_light
      transition: '1'
      brightness: '{{ 255 if state_attr("light.0xb0ce1814033b6827_light", "brightness") == 5 else 5 }}'
...

Wrap-up

This automation leads me to use my bedside lamp much more than the ceiling light, and being able to carry the button to bed and attach it above the bed head makes it much easier to control the lamp without needing to reach all the way over the bedside table.

This article is part of the Home automation set.


Feedback? Questions? Email me