Sensor for computer usage?

The xprintidle solution from martokk is awesome, simple and very versatile… except for a tiny issue: getting SSH to run properly from the command_line integration seems to be a nightmare (sample complaint post from 2020).

  • You obviously can’t pass a password via argument to ssh
  • no clue if it’s ever possible to install sshpass in HA Core
  • SSH keys seem to be wiped with Core updates (reply at the same post)
    • I mean, if you ever figure out how to add a working SSH key; the SSH add-on don’t run at the same container which the integration will execute (reply at the same post, integration docs “hint”), so testing from the add-on and seeing it working fine makes you feel like a :clown_face:

Other solutions I’m leaning towards:

  • edit [THIS ONE WORKED!!!] installing some sort of HTTP server on my computer and make it spit out xprintidle whenever a given page is requested… so somehow HA can pick that up through, idk, curl? Nonetheless, that’s a lot of work which could be simply done via SSH lol
    1. I indeed installed Apache in my computer
    2. I added a cronjob to store xprintidle output in Apache’s folder: crontab -e; then add */1 * * * * DISPLAY=:0 xprintidle 2>&1 > /var/www/html/xprintidle.txt
      • 2-year later note: after reinstalling my OS, I lost the cronjob and tried to do it by hand, before finding this very own post. Turns out this can’t be done directly with PHP (e.g. <? passthru('xprintidle');) because that process won’t be executed by your actual user lol
    3. I added a command_line integration to HA which runs curl my-desktop-ip/xprintidle.txt :pray: Dirtiest solution possible, but… that’s what we have to put up with sometimes around Home Assistant “user-friendly” configurations? lol
  • some indirect trick with System Bridge
  • hope for something like HASS.Agent but for Linux lol