Integrate computers into presence detection

I’m building a background service to integrate any computer into Home Assistant. I’m using it for presence detection as well as to control the backlight of a Raspberry Pi with Touchscreen.

Currently this only works on Linux, if someone knows how to detect user input on Windows and macOS i’ll integrate it.
I’ve tested it on Linux as well as macOS, a Windows binary is available but I have not tested it.
I would like to create a cross-platform alternative to iotlink which works only on Windows as of now.

I’m using it with the Magic Areas component to keep the light turned on while I’m using the pc so I don’t have to wink at the motion sensor every now and then.

Here is the repository: maxjoehnk/desktop2mqtt

You can install it with cargo like so:

cargo install desktop2mqtt

I’ll publish it on crates.io when my fix for xidlehook gets merged.
I’ve also attached a .deb file on the release but couldn’t actually test it yet as I don’t have a debian machine at hand. It’s packaged via cargo-deb so I’m fairly certain about it working just fine.

I hope some of you find it useful!

For those interested here is my automation i’m using to set the dashboard brightness:

alias: 0 Global - Dashboard - Active
description: Increase the Dashboard background brightness when using
trigger:
  - type: occupied
    platform: device
    device_id: 7a7e3f012123dfc33600123b99ada943
    entity_id: binary_sensor.dashboard_occupancy
    domain: binary_sensor
condition: []
action:
  - service: script.0_global_dashboard_set_backlight_active
  - wait_for_trigger:
      - type: not_occupied
        platform: device
        device_id: 7a7e3f012123dfc33600123b99ada943
        entity_id: binary_sensor.dashboard_occupancy
        domain: binary_sensor
  - service: script.0_global_dashboard_set_backlight_idle
mode: single

as well as the scripts used to set the brightness:

alias: 0 Global - Dashboard - Set backlight active
sequence:
  - data:
      brightness: '{{ states(''input_number.dashboard_brightness'') }}'
      entity_id: light.dashboard_backlight
    service: light.turn_on
    entity_id: light.dashboard_backlight
mode: single
icon: 'mdi:brightness-7'
alias: 0 Global - Dashboard - Set backlight idle
sequence:
  - data:
      brightness: '{{ states(''input_number.dashboard_idle_brightness'') }}'
      entity_id: light.dashboard_backlight
    service: light.turn_on
    entity_id: light.dashboard_backlight
mode: single
icon: 'mdi:brightness-5'
1 Like