Sit stand desk with computer: reminder to change your position

I have a sit stand desk, but I often forget to change my position. So, I’ve decided to make a notification for that. I’ve considered various methods for (1) detecting my presence at the desk and (2) detecting position change. Finally, I’ve found that it can be done with just one smart socket that can measure power:

  1. My presence at the desk strongly correlates with my screen being turned on. This can be detected by a smart socket.
  2. When I change the position of the desk, it can also be detected by a smart socket.

You might wonder how to detect both by a single socket. When I change the position of the desk, it draws substantially more power than the screen. I did the measurements this way:

  1. Measure minimum and maximum screen power. This can be tricky for OLED screens, as they might draw pretty little power when displaying something rather black. It is much easier for LCD screens, where it can be enough to measure the power for minimum and maximum brightness.
  2. Measure power drawn by changing the position of the desk. In my case, the power can jump very much, but it always generates a spike that is higher than maximum screen power.
  3. Measure power drawn when both are off. (Screen has to be actually off, not just display black.) If you have power-saving screen and desk, you can get even 0W. (But this will also depend on accuracy of your smart socket.)
  4. Determine range that means your screen is on and your desk doesn’t move. In my case, screen at the lowest brightness draws something like 16W. I’ve picked 10W as the lower bound. Screen at the highest brightness uses something like 42W. I’ve picked 50W as the upper bound. This has resulted in this template:
"template":
- "binary_sensor":
    "name": "I am at computer without position change"
    "state": '{{ (10.0 <= (states("sensor.socket_power") | float)) and ((states("sensor.socket_power") | float) <= 50.0) }}'
  1. Create an automation that notifies you when the sensor above is on for some time (e.g., 1h):
"automation computer_desk_change_position_notification":
  "alias": "Change position at the computer desk"
  "id": "computer_desk_change_position_notification"
  "trigger":
  - "platform": "state"
    "entity_id":
    - "binary_sensor.i_am_at_computer_without_position_change"
    "to": "on"
    "for":
      "seconds": !!int "3600"
  "condition": []
  "mode": "single"
  "action":
  - "service": "notify.notify"
    "data":
      "message": "Change your position at the desk!"
      "data":
        "tag": "computer_desk_change_position_notification"