Git Product home page Git Product logo

bkbilly / lnxlink Goto Github PK

View Code? Open in Web Editor NEW
243.0 4.0 29.0 1.81 MB

🖥 Effortlessly manage your Linux machine using MQTT.

Home Page: https://bkbilly.gitbook.io/lnxlink

License: MIT License

Python 98.51% Shell 1.08% Dockerfile 0.41%
mqtt iot systemd-service linux companion-app home-assistant home-automation integration notifications sensors smarthome automation command-execution control remote-monitoring remote-control

lnxlink's Introduction

license OS - Linux Python 3.7 PyPI Last commit

LNXlink

LNXlink is a Linux companion app that seamlessly integrates your system with external applications like Home Assistant. It uses MQTT, a lightweight messaging protocol, to enable real-time data exchange and remote control capabilities.

With LNXlink, you can monitor your Linux machine's performance, execute commands remotely, and integrate it into your smart home ecosystem for centralized management.

Key Features

  • Sensor Monitoring: Automatically or manually expose sensors that monitor and control the system remotely.
  • Home Assistant: Utilizes MQTT Autodiscovery to create entities in Home Assistant dashboard.
  • Easy Installation: No sudo privileges required for installation and operation, except for server environments.
  • Expandable Architecture: Automatically imports new modules and allows for the addition of custom modules.

lnxlink_sensors2

Get started

To get started with LNXlink, follow these simple steps:

  • Download the LNXlink application and install it on your Linux machine: pipx install lnxlink
  • Follow the configuration instructions to setup LNXlink: lnxlink -c lnxlink.yaml
  • Install and configure on Home Assistant the hass-mqtt-mediaplayer integration.
  • Enjoy real-time monitoring and control of your Linux machine from your Home Assistant dashboard.

For detailed installation instructions, please refer to the documentation page: bkbilly.gitbook.io/lnxlink.

Benefits

  • Cross-Platform Compatibility: Runs on any Linux distribution, providing flexibility and wide-ranging compatibility.
  • Enhanced System Insights: Gain real-time insights into your Linux machine's performance by monitoring essential system metrics.
  • Remote Command Execution: Execute arbitrary commands directly from your Home Assistant dashboard, granting remote control over your Linux machine.
  • Seamless Integration with Home Assistant: Integrate your Linux machine into your smart home ecosystem for unified control and monitoring.
  • Automate tasks: Set up automated tasks to perform repetitive actions and save yourself time and effort.

Support LNXlink's Development

To contribute to the development of LNXlink, you can sponsor the project through GitHub Sponsors or PayPal. Your support will help maintain the project, add new features, and fix bugs.

lnxlink's People

Contributors

4m1g0 avatar arsomesan avatar bkbilly avatar cbrand avatar horotw avatar izzeho avatar kamaradclimber avatar matthijsy avatar pacjo avatar pw999 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lnxlink's Issues

Service keeps crashing

Whenever i try to start the lnxlink service it crashes.

running " systemctl --user status lnxlink " returns the following:

lnxlink.service - LNXLink
Loaded: loaded (/home/leon/.config/systemd/user/lnxlink.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2022-01-03 20:35:10 CET; 43s ago
Process: 5666 ExecStart=/usr/bin/python3 /opt/lnxlink/run.py (code=exited, status=1/FAILURE)
Main PID: 5666 (code=exited, status=1/FAILURE)

Jan 03 20:35:10 leon-KDE systemd[3520]: lnxlink.service: Scheduled restart job, restart counter is at 6.
Jan 03 20:35:10 leon-KDE systemd[3520]: Stopped LNXLink.
Jan 03 20:35:10 leon-KDE systemd[3520]: lnxlink.service: Start request repeated too quickly.
Jan 03 20:35:10 leon-KDE systemd[3520]: lnxlink.service: Failed with result 'exit-code'.
Jan 03 20:35:10 leon-KDE systemd[3520]: Failed to start LNXLink.

Feature Request: GPU info

Show information about GPU usage, memory and temperature

nvidia-smi --query-gpu=utilization.gpu,utilization.memory,temperature.gpu --format=csv,noheader,nounits

Shows active on system suspend

Describe the problem
When the system suspends/sleeps, the status on Home Assistant shows ON, though it should become OFF.

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • Version: 2023.1.4

Additional context
On wake up it should turn back to ON.

Select Grub Next Boot

Describe the solution you'd like
Select the next boot option from a dropdown menu

Additional context

List grub menus

import re


def get_grub_entries_with_submenus():
    menu_pattern = re.compile("^menuentry '([^']*)'")
    submenu_pattern = re.compile("^submenu '([^']*)'")

    grub_entries = []

    with open('/boot/grub/grub.cfg') as f:
        for line in f.readlines():
            menu_entry_match = re.match(menu_pattern, line)
            if menu_entry_match:
                grub_entry = menu_entry_match.group(1)
                grub_entries.append(grub_entry)

            submenu_entry_match = re.match(submenu_pattern, line)
            if submenu_entry_match:
                grub_entry = submenu_entry_match.group(1)
                grub_entries.append(grub_entry)

    return grub_entries


menuitems = get_grub_entries_with_submenus()
for num, menu in enumerate(menuitems):
    print(num, menu)

Set the next boot option

sudo grub-reboot 2

Get the next boot option

grub-editenv list

Run command without password

sudo visudo

Add this line:

bkbilly ALL=(ALL) NOPASSWD: /usr/sbin/grub-reboot

Installation error on Ubuntu 22.04 with pip3

Hello there,

your project looks interesting and I'd like to try it out, but can't finish the installation. I install as per your instructions with pip3 install -U lnxlink. The problem then seems to be about compiling the dbus dependency. See the attached logs for more details: lnxlink_installation.log.

Thank you for your time.

Expose Stat Send Interval to Config

Have been playing with this tool and it's pretty handy. Worked out of the box on most devices. I've turned off most of the stats for most client devices, as it's pretty noisy. I had a brief look at the timer and the interval is 5 seconds, is it possible to expose this as an optional setting in the config?

Plenty of functions in linux to get CPU averages over X period as well, I didn't dig to see if the CPU usage now is instantaneous or average.

Feature request: System Restart Required (sensor)

Describe the solution you'd like
Add new sensor to Home Assistant that indicate if a 'System restart is required'.

Additional context
cat /var/run/reboot-required (*** System restart required ***) or via script?

New module for monitor brightness control

Describe the solution you'd like
Change the brightness of connected monitors using a slider.

Additional context
Read current values of monitor brightness and others:

xrandr --verbose --current

Regular Expression for extracting the current connected monitors and their brightness:

^(\S+) \bconnected\b.*[\s\S]*?(?=Brightness)Brightness: ([\d\.\d]+)

Set the brightness for monitor:

xrandr --output "DP-1" --brightness "0.8"

Almalinux install

For reference the installation on Almalinux works using the following:
dnf install python39-pip.noarch gcc cmake dbus-devel glib2-devel python39-devel alsa-lib-devel
(default pip3 on almalinux 8 does not work)

I suspect this also would work on Centos but can't test it.

xdotool xprintidle are not expected to work on wayland. xprintidle seems to replaced by dbus (https://unix.stackexchange.com/questions/396911/how-can-i-tell-if-a-user-is-idle-in-wayland/492328#492328).

I've used https://git.sr.ht/~geb/dotool/archive/1.1.tar.gz to replaced xdotool on another project but it is not in any RPM repo.

Error updating to 2023.4.1 from 2023.4.0

Describe the problem
2023.4.0 updated successfully and has been running for a while. Today I tried updating to 2023.4.1, and now I'm getting the following error:

Traceback (most recent call last):
  File "/home/ben/.local/bin/lnxlink", line 8, in <module>
    sys.exit(main())
  File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 292, in main
    lnxlink = LNXlink(config_file)
  File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 32, in __init__
    self.Addons[addon.service] = addon(self)
  File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 9, in __init__
    self.options = self._get_grub_entries()
  File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 42, in _get_grub_entries
    with open('/boot/grub/grub.cfg') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/boot/grub/grub.cfg'

So far I'm not sure how to solve that one, it seems to be related to the new feature added in 2023.4.1 to select a boot option.

Additionally, I was getting the following message:

Addon screenshot is not supported, please remove it from your config
No module named 'mss'

For that one, I manually ran pip3 install mss and then it started working. Shouldn't that be installed as a dependency of lnxlink, or is it expected that it needs to be installed separately?

Desktop (please complete the following information):

  • OS: Pop_OS! 22.04
  • Version: 2023.4.1

Additional context

Pop_OS! uses Systemd-boot instead of Grub

Configuration
Provide the configuration file, remove any sensitive info that might exist:

mqtt:
  prefix: lnxlink
  clientId: Dev-Laptop
  statsPrefix: monitor/stats
  server: homeassistant.local
  port: 1883
  auth:
    user: **redacted**
    pass: **redacted**
  discovery:
    enabled: true
  lwt:
    enabled: true
    qos: 1
    retain: true
    connectMsg: 'ON'
    disconnectMsg: 'OFF'
update_interval: 5

Logs

Apr 17 12:17:40 pop-os lnxlink[122093]: Traceback (most recent call last):
Apr 17 12:17:40 pop-os lnxlink[122093]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 62, in monitor_run
Apr 17 12:17:40 pop-os lnxlink[122093]:     pub_data = addon.getInfo()
Apr 17 12:17:40 pop-os lnxlink[122093]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/disk_usage.py", line 17, in getInfo
Apr 17 12:17:40 pop-os lnxlink[122093]:     disk_stats = psutil.disk_usage(disk.mountpoint)
Apr 17 12:17:40 pop-os lnxlink[122093]:   File "/usr/lib/python3/dist-packages/psutil/__init__.py", line 2003, in disk_usage
Apr 17 12:17:40 pop-os lnxlink[122093]:     return _psplatform.disk_usage(path)
Apr 17 12:17:40 pop-os lnxlink[122093]:   File "/usr/lib/python3/dist-packages/psutil/_psposix.py", line 170, in disk_usage
Apr 17 12:17:40 pop-os lnxlink[122093]:     st = os.statvfs(path)
Apr 17 12:17:40 pop-os lnxlink[122093]: PermissionError: [Errno 13] Permission denied: '/var/lib/docker/tmp/buildkit-mount879119100'
Apr 18 08:28:34 pop-os systemd[4682]: Stopping LNXLink...
Apr 18 08:28:35 pop-os systemd[4682]: lnxlink.service: Main process exited, code=exited, status=1/FAILURE
Apr 18 08:28:35 pop-os systemd[4682]: lnxlink.service: Failed with result 'exit-code'.
Apr 18 08:28:35 pop-os systemd[4682]: Stopped LNXLink.
Apr 18 08:28:35 pop-os systemd[4682]: lnxlink.service: Consumed 1d 19h 52min 58.853s CPU time.
-- Boot 4b09bf8358ea4368b81f29800964fffd --
Apr 18 09:43:09 pop-os systemd[4834]: Started LNXLink.
Apr 18 09:43:10 pop-os lnxlink[4845]: Traceback (most recent call last):
Apr 18 09:43:10 pop-os lnxlink[4845]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 62, in monitor_run
Apr 18 09:43:10 pop-os lnxlink[4845]:     pub_data = addon.getInfo()
Apr 18 09:43:10 pop-os lnxlink[4845]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/idle.py", line 16, in getInfo
Apr 18 09:43:10 pop-os lnxlink[4845]:     idle_ms = monitor.get_dbus_idle()
Apr 18 09:43:10 pop-os lnxlink[4845]:   File "/home/ben/.local/lib/python3.10/site-packages/dbus_idle/__init__.py", line 105, in get_dbus_idle
Apr 18 09:43:10 pop-os lnxlink[4845]:     idle_sec = int(stdout.strip())
Apr 18 09:43:10 pop-os lnxlink[4845]: ValueError: invalid literal for int() with base 10: ''
-- Boot 983ce4a82a52487082a0a2029a0a5495 --
Apr 24 09:27:54 pop-os systemd[4804]: Started LNXLink.
Apr 24 09:27:55 pop-os lnxlink[4814]: Traceback (most recent call last):
Apr 24 09:27:55 pop-os lnxlink[4814]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 62, in monitor_run
Apr 24 09:27:55 pop-os lnxlink[4814]:     pub_data = addon.getInfo()
Apr 24 09:27:55 pop-os lnxlink[4814]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/idle.py", line 16, in getInfo
Apr 24 09:27:55 pop-os lnxlink[4814]:     idle_ms = monitor.get_dbus_idle()
Apr 24 09:27:55 pop-os lnxlink[4814]:   File "/home/ben/.local/lib/python3.10/site-packages/dbus_idle/__init__.py", line 105, in get_dbus_idle
Apr 24 09:27:55 pop-os lnxlink[4814]:     idle_sec = int(stdout.strip())
Apr 24 09:27:55 pop-os lnxlink[4814]: ValueError: invalid literal for int() with base 10: ''
Apr 26 11:33:43 pop-os lnxlink[4814]: LNXlink 2023.4.0 started: 3.10.6
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: camera_used
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: send_keys
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: battery
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: idle
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: keep_alive
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: restart
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: sys_updates
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: cpu
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: shutdown
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: suspend
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: screen_onoff
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: required_restart
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: memory
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: media
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: network_download
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: nvidia_gpu
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: update
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: disk_usage
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: microphone_used
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: xdg_open
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: notify
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: webcam
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: network_upload
Apr 26 11:33:43 pop-os lnxlink[4814]: Successfully loaded addon: bash
Apr 26 11:33:43 pop-os lnxlink[4814]: Can't load addon: idle
Apr 26 11:33:43 pop-os lnxlink[4814]: Connected to MQTT with code 0
Apr 26 11:33:43 pop-os lnxlink[4814]: Connected to MQTT with code 0
Apr 26 11:33:43 pop-os lnxlink[4814]: stopped gracefully
Apr 26 11:33:43 pop-os lnxlink[4814]: Disconnected from MQTT.
Apr 26 11:33:44 pop-os systemd[4804]: lnxlink.service: Consumed 6h 50min 28.781s CPU time.
Apr 26 11:33:44 pop-os systemd[4804]: lnxlink.service: Scheduled restart job, restart counter is at 1.
Apr 26 11:33:44 pop-os systemd[4804]: Stopped LNXLink.
Apr 26 11:33:44 pop-os systemd[4804]: lnxlink.service: Consumed 6h 50min 28.781s CPU time.
Apr 26 11:33:44 pop-os systemd[4804]: Started LNXLink.
Apr 26 11:33:44 pop-os lnxlink[1311164]: LNXlink 2023.4.1 started: 3.10.6
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: camera_used
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: send_keys
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: battery
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: idle
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: keep_alive
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: restart
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: sys_updates
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: cpu
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: shutdown
Apr 26 11:33:44 pop-os lnxlink[1311164]: Addon screenshot is not supported, please remove it from your config
Apr 26 11:33:44 pop-os lnxlink[1311164]: No module named 'mss'
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: suspend
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: brightness
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: boot_select
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: screen_onoff
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: required_restart
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: memory
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: media
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: network_download
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: nvidia_gpu
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: update
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: disk_usage
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: microphone_used
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: xdg_open
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: notify
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: webcam
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: network_upload
Apr 26 11:33:44 pop-os lnxlink[1311164]: Successfully loaded addon: bash
Apr 26 11:33:44 pop-os lnxlink[1311164]: Traceback (most recent call last):
Apr 26 11:33:44 pop-os lnxlink[1311164]:   File "/home/ben/.local/bin/lnxlink", line 8, in <module>
Apr 26 11:33:44 pop-os lnxlink[1311164]:     sys.exit(main())
Apr 26 11:33:44 pop-os lnxlink[1311164]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 292, in main
Apr 26 11:33:44 pop-os lnxlink[1311164]:     lnxlink = LNXlink(config_file)
Apr 26 11:33:44 pop-os lnxlink[1311164]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 32, in __init__
Apr 26 11:33:44 pop-os lnxlink[1311164]:     self.Addons[addon.service] = addon(self)
Apr 26 11:33:44 pop-os lnxlink[1311164]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 9, in __init__
Apr 26 11:33:44 pop-os lnxlink[1311164]:     self.options = self._get_grub_entries()
Apr 26 11:33:44 pop-os lnxlink[1311164]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 42, in _get_grub_entries
Apr 26 11:33:44 pop-os lnxlink[1311164]:     with open('/boot/grub/grub.cfg') as f:
Apr 26 11:33:44 pop-os lnxlink[1311164]: FileNotFoundError: [Errno 2] No such file or directory: '/boot/grub/grub.cfg'
Apr 26 11:33:44 pop-os systemd[4804]: lnxlink.service: Main process exited, code=exited, status=1/FAILURE
Apr 26 11:33:44 pop-os systemd[4804]: lnxlink.service: Failed with result 'exit-code'.
Apr 26 11:33:45 pop-os systemd[4804]: lnxlink.service: Scheduled restart job, restart counter is at 2.
Apr 26 11:33:45 pop-os systemd[4804]: Stopped LNXLink.
Apr 26 11:33:45 pop-os systemd[4804]: Started LNXLink.
Apr 26 11:33:45 pop-os lnxlink[1311169]: LNXlink 2023.4.1 started: 3.10.6
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: camera_used
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: send_keys
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: battery
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: idle
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: keep_alive
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: restart
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: sys_updates
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: cpu
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: shutdown
Apr 26 11:33:45 pop-os lnxlink[1311169]: Addon screenshot is not supported, please remove it from your config
Apr 26 11:33:45 pop-os lnxlink[1311169]: No module named 'mss'
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: suspend
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: brightness
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: boot_select
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: screen_onoff
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: required_restart
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: memory
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: media
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: network_download
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: nvidia_gpu
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: update
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: disk_usage
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: microphone_used
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: xdg_open
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: notify
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: webcam
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: network_upload
Apr 26 11:33:45 pop-os lnxlink[1311169]: Successfully loaded addon: bash
Apr 26 11:33:45 pop-os lnxlink[1311169]: Traceback (most recent call last):
Apr 26 11:33:45 pop-os lnxlink[1311169]:   File "/home/ben/.local/bin/lnxlink", line 8, in <module>
Apr 26 11:33:45 pop-os lnxlink[1311169]:     sys.exit(main())
Apr 26 11:33:45 pop-os lnxlink[1311169]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 292, in main
Apr 26 11:33:45 pop-os lnxlink[1311169]:     lnxlink = LNXlink(config_file)
Apr 26 11:33:45 pop-os lnxlink[1311169]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 32, in __init__
Apr 26 11:33:45 pop-os lnxlink[1311169]:     self.Addons[addon.service] = addon(self)
Apr 26 11:33:45 pop-os lnxlink[1311169]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 9, in __init__
Apr 26 11:33:45 pop-os lnxlink[1311169]:     self.options = self._get_grub_entries()
Apr 26 11:33:45 pop-os lnxlink[1311169]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 42, in _get_grub_entries
Apr 26 11:33:45 pop-os lnxlink[1311169]:     with open('/boot/grub/grub.cfg') as f:
Apr 26 11:33:45 pop-os lnxlink[1311169]: FileNotFoundError: [Errno 2] No such file or directory: '/boot/grub/grub.cfg'
Apr 26 11:33:45 pop-os systemd[4804]: lnxlink.service: Main process exited, code=exited, status=1/FAILURE
Apr 26 11:33:45 pop-os systemd[4804]: lnxlink.service: Failed with result 'exit-code'.
Apr 26 11:33:45 pop-os systemd[4804]: lnxlink.service: Scheduled restart job, restart counter is at 3.
Apr 26 11:33:45 pop-os systemd[4804]: Stopped LNXLink.
Apr 26 11:33:45 pop-os systemd[4804]: Started LNXLink.
Apr 26 11:33:46 pop-os lnxlink[1311174]: LNXlink 2023.4.1 started: 3.10.6
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: camera_used
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: send_keys
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: battery
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: idle
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: keep_alive
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: restart
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: sys_updates
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: cpu
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: shutdown
Apr 26 11:33:46 pop-os lnxlink[1311174]: Addon screenshot is not supported, please remove it from your config
Apr 26 11:33:46 pop-os lnxlink[1311174]: No module named 'mss'
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: suspend
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: brightness
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: boot_select
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: screen_onoff
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: required_restart
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: memory
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: media
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: network_download
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: nvidia_gpu
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: update
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: disk_usage
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: microphone_used
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: xdg_open
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: notify
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: webcam
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: network_upload
Apr 26 11:33:46 pop-os lnxlink[1311174]: Successfully loaded addon: bash
Apr 26 11:33:46 pop-os lnxlink[1311174]: Traceback (most recent call last):
Apr 26 11:33:46 pop-os lnxlink[1311174]:   File "/home/ben/.local/bin/lnxlink", line 8, in <module>
Apr 26 11:33:46 pop-os lnxlink[1311174]:     sys.exit(main())
Apr 26 11:33:46 pop-os lnxlink[1311174]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 292, in main
Apr 26 11:33:46 pop-os lnxlink[1311174]:     lnxlink = LNXlink(config_file)
Apr 26 11:33:46 pop-os lnxlink[1311174]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 32, in __init__
Apr 26 11:33:46 pop-os lnxlink[1311174]:     self.Addons[addon.service] = addon(self)
Apr 26 11:33:46 pop-os lnxlink[1311174]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 9, in __init__
Apr 26 11:33:46 pop-os lnxlink[1311174]:     self.options = self._get_grub_entries()
Apr 26 11:33:46 pop-os lnxlink[1311174]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 42, in _get_grub_entries
Apr 26 11:33:46 pop-os lnxlink[1311174]:     with open('/boot/grub/grub.cfg') as f:
Apr 26 11:33:46 pop-os lnxlink[1311174]: FileNotFoundError: [Errno 2] No such file or directory: '/boot/grub/grub.cfg'
Apr 26 11:33:46 pop-os systemd[4804]: lnxlink.service: Main process exited, code=exited, status=1/FAILURE
Apr 26 11:33:46 pop-os systemd[4804]: lnxlink.service: Failed with result 'exit-code'.
Apr 26 11:33:46 pop-os systemd[4804]: lnxlink.service: Scheduled restart job, restart counter is at 4.
Apr 26 11:33:46 pop-os systemd[4804]: Stopped LNXLink.
Apr 26 11:33:46 pop-os systemd[4804]: Started LNXLink.
Apr 26 11:33:47 pop-os lnxlink[1311196]: LNXlink 2023.4.1 started: 3.10.6
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: camera_used
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: send_keys
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: battery
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: idle
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: keep_alive
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: restart
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: sys_updates
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: cpu
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: shutdown
Apr 26 11:33:47 pop-os lnxlink[1311196]: Addon screenshot is not supported, please remove it from your config
Apr 26 11:33:47 pop-os lnxlink[1311196]: No module named 'mss'
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: suspend
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: brightness
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: boot_select
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: screen_onoff
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: required_restart
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: memory
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: media
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: network_download
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: nvidia_gpu
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: update
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: disk_usage
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: microphone_used
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: xdg_open
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: notify
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: webcam
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: network_upload
Apr 26 11:33:47 pop-os lnxlink[1311196]: Successfully loaded addon: bash
Apr 26 11:33:47 pop-os lnxlink[1311196]: Traceback (most recent call last):
Apr 26 11:33:47 pop-os lnxlink[1311196]:   File "/home/ben/.local/bin/lnxlink", line 8, in <module>
Apr 26 11:33:47 pop-os lnxlink[1311196]:     sys.exit(main())
Apr 26 11:33:47 pop-os lnxlink[1311196]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 292, in main
Apr 26 11:33:47 pop-os lnxlink[1311196]:     lnxlink = LNXlink(config_file)
Apr 26 11:33:47 pop-os lnxlink[1311196]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 32, in __init__
Apr 26 11:33:47 pop-os lnxlink[1311196]:     self.Addons[addon.service] = addon(self)
Apr 26 11:33:47 pop-os lnxlink[1311196]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 9, in __init__
Apr 26 11:33:47 pop-os lnxlink[1311196]:     self.options = self._get_grub_entries()
Apr 26 11:33:47 pop-os lnxlink[1311196]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 42, in _get_grub_entries
Apr 26 11:33:47 pop-os lnxlink[1311196]:     with open('/boot/grub/grub.cfg') as f:
Apr 26 11:33:47 pop-os lnxlink[1311196]: FileNotFoundError: [Errno 2] No such file or directory: '/boot/grub/grub.cfg'
Apr 26 11:33:47 pop-os systemd[4804]: lnxlink.service: Main process exited, code=exited, status=1/FAILURE
Apr 26 11:33:47 pop-os systemd[4804]: lnxlink.service: Failed with result 'exit-code'.
Apr 26 11:33:47 pop-os systemd[4804]: lnxlink.service: Scheduled restart job, restart counter is at 5.
Apr 26 11:33:47 pop-os systemd[4804]: Stopped LNXLink.
Apr 26 11:33:47 pop-os systemd[4804]: Started LNXLink.
Apr 26 11:33:47 pop-os lnxlink[1311201]: LNXlink 2023.4.1 started: 3.10.6
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: camera_used
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: send_keys
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: battery
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: idle
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: keep_alive
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: restart
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: sys_updates
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: cpu
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: shutdown
Apr 26 11:33:47 pop-os lnxlink[1311201]: Addon screenshot is not supported, please remove it from your config
Apr 26 11:33:47 pop-os lnxlink[1311201]: No module named 'mss'
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: suspend
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: brightness
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: boot_select
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: screen_onoff
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: required_restart
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: memory
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: media
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: network_download
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: nvidia_gpu
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: update
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: disk_usage
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: microphone_used
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: xdg_open
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: notify
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: webcam
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: network_upload
Apr 26 11:33:47 pop-os lnxlink[1311201]: Successfully loaded addon: bash
Apr 26 11:33:47 pop-os lnxlink[1311201]: Traceback (most recent call last):
Apr 26 11:33:47 pop-os lnxlink[1311201]:   File "/home/ben/.local/bin/lnxlink", line 8, in <module>
Apr 26 11:33:47 pop-os lnxlink[1311201]:     sys.exit(main())
Apr 26 11:33:47 pop-os lnxlink[1311201]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 292, in main
Apr 26 11:33:47 pop-os lnxlink[1311201]:     lnxlink = LNXlink(config_file)
Apr 26 11:33:47 pop-os lnxlink[1311201]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 32, in __init__
Apr 26 11:33:47 pop-os lnxlink[1311201]:     self.Addons[addon.service] = addon(self)
Apr 26 11:33:47 pop-os lnxlink[1311201]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 9, in __init__
Apr 26 11:33:47 pop-os lnxlink[1311201]:     self.options = self._get_grub_entries()
Apr 26 11:33:47 pop-os lnxlink[1311201]:   File "/home/ben/.local/lib/python3.10/site-packages/lnxlink/modules/boot_select.py", line 42, in _get_grub_entries
Apr 26 11:33:47 pop-os lnxlink[1311201]:     with open('/boot/grub/grub.cfg') as f:
Apr 26 11:33:47 pop-os lnxlink[1311201]: FileNotFoundError: [Errno 2] No such file or directory: '/boot/grub/grub.cfg'
Apr 26 11:33:47 pop-os systemd[4804]: lnxlink.service: Main process exited, code=exited, status=1/FAILURE
Apr 26 11:33:47 pop-os systemd[4804]: lnxlink.service: Failed with result 'exit-code'.
Apr 26 11:33:48 pop-os systemd[4804]: lnxlink.service: Scheduled restart job, restart counter is at 6.
Apr 26 11:33:48 pop-os systemd[4804]: Stopped LNXLink.
Apr 26 11:33:48 pop-os systemd[4804]: lnxlink.service: Start request repeated too quickly.
Apr 26 11:33:48 pop-os systemd[4804]: lnxlink.service: Failed with result 'exit-code'.
Apr 26 11:33:48 pop-os systemd[4804]: Failed to start LNXLink.

Restart instead of shutdown

I think restart might be quite a useful command. I have added it to my install (cant try it yet but will report back) this should be the command.

import subprocess

class Addon():
    service = 'restart'
    name = 'Restart'
    icon = 'mdi:power'
    unit = 'json'

    def startControl(self, topic, data):
        print(topic, data)
        subprocess.call(["shutdown", "-r", "-t", "30"])

[Feature Request] add toggle monitor

Hello I like the idea ..at the moment at the moment I use a mqtr solution to turn on and off my screen.its used for my magic mirror in the toilette.but unfortunately somehow I have to start it manually die to python skills not good. Is there a way to add monitor on off ?

Service seems to stop after a few hours

I am the one with the nuc issue yesterday.

I noticed the service stopped running and I restarted it. It started working as expected and suddenly died again, 6 hours ago. I know something happened as the home assistant sensors are unavailable and they all went unavailable at the same time. Is there a way to access the logs and potentially see what happened before it failed?

Multiple media players

When multiple players exist at the same time, only the first one will be used.
The app must check which one is playing and select that.

Feature Request: Disk Usage

Something equivalent to the following:

Filesystem

~> df -hT | grep -v 'Filesystem' | grep -v tmpfs | awk '{ print $1 }'
/dev/mapper/laptop-vg-root
/dev/nvme0n1p2
/dev/nvme0n1p1

Size

~> df -hT | grep -v 'Filesystem' | grep -v tmpfs | awk '{ print $3 }'
186G
471M
511M

Used

~> df -hT | grep -v 'Filesystem' | grep -v tmpfs | awk '{ print $4 }'
124G
231M
5.8M

Avail

~> df -hT | grep -v 'Filesystem' | grep -v tmpfs | awk '{ print $5 }'
52G
216M
506M

Use%

~> df -hT | grep -v 'Filesystem' | grep -v tmpfs | awk '{ print $6 }'
71%
52%
2%

TTS Playback on LNX link Device

Describe the solution you'd like
The ability to play TTS on a LNX link device. I tried to use Browser Mod, but across several different computers of different operating systems, the media player portion doesn't work at all. I haven't gotten any help from that project, so I've just about given up on it working for me in that way. This seems close, just not able to play TTS.

Additional context
I couldn't figure out how to play media, only pause/play, although not sure if I would use for actual media playback or not.

Memory Reporting Enhancements

Describe the solution you'd like
I am proposing the inclusion of additional Memory measurements, not just percentage, but the addition of In-Use and Total. This appears as an available option of the current psutil utility.

Additional context
I believe I have identified the python code needed, but its my first go at python, so may be incorrect.

# Memory In-Use

import psutil

class Addon():

    def __init__(self, lnxlink):
        self.name = 'Memory In Use'
        self.sensor_type = 'sensor'
        self.icon = 'mdi:memory'
        self.unit = 'GB'
        self.state_class = 'measurement'
        self.device_class = 'data_size'

    def getInfo(self):
        memory_info = psutil.virtual_memory().used
        in_use_gb = round(memory_info / 1024 ** 3, 1)
        return in_use_gb
# Memory Total

import psutil

class Addon():

    def __init__(self, lnxlink):
        self.name = 'Memory Total'
        self.sensor_type = 'sensor'
        self.icon = 'mdi:memory'
        self.unit = 'GB'
        self.state_class = 'measurement'
        self.device_class = 'data_size'

    def getInfo(self):
        memory_info = psutil.virtual_memory().total
        total_gb = round(memory_info / 1024 ** 3, 1)
        return total_gb

Error with notifications: asynchronous calls

Describe the problem
With the recent update, I now have an error when receiving notification

Desktop (please complete the following information):

  • OS: Fedora 37
  • Version 2023.3.1

Additional context
Using MQTT to send a notification to my laptop, I never receive it. Instead, some errors appear in the logs.

I believe it was not the case with the previous release.

Configuration
Provide the configuration file, remove any sensitive info that might exist:

mqtt:
  prefix: lnxlink
  clientId: bflap
  statsPrefix: monitor/stats
  server: xxx
  port: xxx
  auth:
    user: xxx
    pass: xxx
  discovery:
    enabled: true
  lwt:
    enabled: true
    qos: 1
    retain: true
    connectMsg: 'ON'
    disconnectMsg: 'OFF'
update_interval: 5
modules:
#- bash
#- bluetooth_battery
- camera_used
- cpu
#- disk_usage
- idle
- keep_alive
#- media
- memory
- microphone_used
- network_download
- network_upload
- notify
#- nvidia_gpu
- required_restart
#- restart
#- screen_onoff
#- send_keys
#- shutdown
#- suspend
- update
#- xdg_open                   

Logs

Mar 30 00:00:00 bflap lnxlink[718304]: Traceback (most recent call last):
Mar 30 00:00:00 bflap lnxlink[718304]:   File "/home/guik/.local/lib/python3.11/site-packages/lnxlink/__main__.py", line 163, in on_message
Mar 30 00:00:00 bflap lnxlink[718304]:     addon.startControl(select_service, message)
Mar 30 00:00:00 bflap lnxlink[718304]:   File "/home/guik/.local/lib/python3.11/site-packages/lnxlink/modules/notify.py", line 23, in startControl
Mar 30 00:00:00 bflap lnxlink[718304]:     notify2.init("Test")
Mar 30 00:00:00 bflap lnxlink[718304]:   File "/home/guik/.local/lib/python3.11/site-packages/notify2.py", line 111, in init
Mar 30 00:00:00 bflap lnxlink[718304]:     dbus_iface.connect_to_signal('ActionInvoked', _action_callback)
Mar 30 00:00:00 bflap lnxlink[718304]:   File "/usr/lib64/python3.11/site-packages/dbus/proxies.py", line 543, in connect_to_signal
Mar 30 00:00:00 bflap lnxlink[718304]:     return self._obj.connect_to_signal(signal_name, handler_function,
Mar 30 00:00:00 bflap lnxlink[718304]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Mar 30 00:00:00 bflap lnxlink[718304]:   File "/usr/lib64/python3.11/site-packages/dbus/proxies.py", line 366, in connect_to_signal
Mar 30 00:00:00 bflap lnxlink[718304]:     self._bus.add_signal_receiver(handler_function,
Mar 30 00:00:00 bflap lnxlink[718304]:   File "/usr/lib64/python3.11/site-packages/dbus/bus.py", line 144, in add_signal_receiver
Mar 30 00:00:00 bflap lnxlink[718304]:     match = super(BusConnection, self).add_signal_receiver(
Mar 30 00:00:00 bflap lnxlink[718304]:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Mar 30 00:00:00 bflap lnxlink[718304]:   File "/usr/lib64/python3.11/site-packages/dbus/connection.py", line 388, in add_signal_receiver
Mar 30 00:00:00 bflap lnxlink[718304]:     self._require_main_loop()
Mar 30 00:00:00 bflap lnxlink[718304]: RuntimeError: To make asynchronous calls, receive signals or export objects, D-Bus connections must be attached to a main loop by passing mainloop=... to the constructor or calling dbus.set_default_main_loop(...)
Mar 30 17:40:00 bflap lnxlink[718304]: Traceback (most recent call last):
Mar 30 17:40:00 bflap lnxlink[718304]:   File "/home/guik/.local/lib/python3.11/site-packages/lnxlink/__main__.py", line 163, in on_message
Mar 30 17:40:00 bflap lnxlink[718304]:     addon.startControl(select_service, message)
Mar 30 17:40:00 bflap lnxlink[718304]:   File "/home/guik/.local/lib/python3.11/site-packages/lnxlink/modules/notify.py", line 23, in startControl
Mar 30 17:40:00 bflap lnxlink[718304]:     notify2.init("Test")
Mar 30 17:40:00 bflap lnxlink[718304]:   File "/home/guik/.local/lib/python3.11/site-packages/notify2.py", line 111, in init
Mar 30 17:40:00 bflap lnxlink[718304]:     dbus_iface.connect_to_signal('ActionInvoked', _action_callback)
Mar 30 17:40:00 bflap lnxlink[718304]:   File "/usr/lib64/python3.11/site-packages/dbus/proxies.py", line 543, in connect_to_signal
Mar 30 17:40:00 bflap lnxlink[718304]:     return self._obj.connect_to_signal(signal_name, handler_function,
Mar 30 17:40:00 bflap lnxlink[718304]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Mar 30 17:40:00 bflap lnxlink[718304]:   File "/usr/lib64/python3.11/site-packages/dbus/proxies.py", line 366, in connect_to_signal
Mar 30 17:40:00 bflap lnxlink[718304]:     self._bus.add_signal_receiver(handler_function,
Mar 30 17:40:00 bflap lnxlink[718304]:   File "/usr/lib64/python3.11/site-packages/dbus/bus.py", line 144, in add_signal_receiver
Mar 30 17:40:00 bflap lnxlink[718304]:     match = super(BusConnection, self).add_signal_receiver(
Mar 30 17:40:00 bflap lnxlink[718304]:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Mar 30 17:40:00 bflap lnxlink[718304]:   File "/usr/lib64/python3.11/site-packages/dbus/connection.py", line 388, in add_signal_receiver
Mar 30 17:40:00 bflap lnxlink[718304]:     self._require_main_loop()
Mar 30 17:40:00 bflap lnxlink[718304]: RuntimeError: To make asynchronous calls, receive signals or export objects, D-Bus connections must be attached to a main loop by passing mainloop=... to the constructor or calling dbus.set_default_main_loop(.

Entities unavailable when restarting home assistant

Firstly, thanks for the app, it's very helpful.

I was having a problem that when i restart home assistant all the entities from the app became unavailable, until i restart the pc, or at least the service.
I know very little about mqtt, but after doing some research, i actually already found a solution: set retain = True to the home assistant auto discovery messages.
But normally the entities should work after restarts even without retaining the messages? And is there some reason to the messages not being retained by default?

I'm running home assistant and mosquitto as docker containers, in case this is relevant.

Trying to make work in headerless linux

Hi just learned about this app, looks great, thanks for putting it together, will be so much better than using SSH. I installed it onto a proxmox host hoping to get some details into HA. The problem is that after entering in all the details im not seeing any attempts to connect on the MQTT broker. Is there any troubleshooting steps you could recommend or any logs i can see from the app?
EDIT:
looking at previous issues i found the below command and the output from it (if you would prefer issues in the github please me know)

root@proxmox:~# systemctl --user status lnxlink
● lnxlink.service - LNXLink
Loaded: loaded (/root/.config/systemd/user/lnxlink.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-01-31 15:29:55 AEDT; 13s ago
Main PID: 96503 (python3)
Tasks: 1 (limit: 38084)
Memory: 16.9M
CPU: 109ms
CGroup: /user.slice/user-0.slice/[email protected]/app.slice/lnxlink.service
└─96503 /usr/bin/python3 /opt/lnxlink/run.py

Jan 31 15:30:07 proxmox python3[96503]: return _bootstrap._gcd_import(name[level:], package, level)
Jan 31 15:30:07 proxmox python3[96503]: File "", line 1030, in _gcd_import
Jan 31 15:30:07 proxmox python3[96503]: File "", line 1007, in _find_and_load
Jan 31 15:30:07 proxmox python3[96503]: File "", line 986, in _find_and_load>
Jan 31 15:30:07 proxmox python3[96503]: File "", line 680, in load_unlocked
Jan 31 15:30:07 proxmox python3[96503]: File "", line 790, in exec
>
Jan 31 15:30:07 proxmox python3[96503]: File "", line 228, in _call_with_fra>
Jan 31 15:30:07 proxmox python3[96503]: File "/opt/lnxlink/modules/media.py", line 1, in
Jan 31 15:30:07 proxmox python3[96503]: from dbus.mainloop.glib import DBusGMainLoop
Jan 31 15:30:07 proxmox python3[96503]: ModuleNotFoundError: No module named 'dbus'
...skipping...
also dbus is installed
root@proxmox:~# sudo apt-get install dbus
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
dbus is already the newest version (1.12.20-2).

root@proxmox:~# pip3 install pydbus
Requirement already satisfied: pydbus in /usr/local/lib/python3.9/dist-packages (0.6.0)

tried installing sudo apt install python3-dbus

but then i get this error

● lnxlink.service - LNXLink
Loaded: loaded (/root/.config/systemd/user/lnxlink.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-01-31 20:32:09 AEDT; 50s ago
Main PID: 149058 (python3)
Tasks: 1 (limit: 38084)
Memory: 20.1M
CPU: 136ms
CGroup: /user.slice/user-0.slice/[email protected]/app.slice/lnxlink.service
└─149058 /usr/bin/python3 /opt/lnxlink/run.py

Jan 31 20:33:00 proxmox python3[149058]: from pynput import keyboard
Jan 31 20:33:00 proxmox python3[149058]: File "/usr/local/lib/python3.9/dist-packages/pynput/init.py", line 40, in
Jan 31 20:33:00 proxmox python3[149058]: from . import keyboard
Jan 31 20:33:00 proxmox python3[149058]: File "/usr/local/lib/python3.9/dist-packages/pynput/keyboard/init.py", line 31, in
Jan 31 20:33:00 proxmox python3[149058]: backend = backend(name)
Jan 31 20:33:00 proxmox python3[149058]: File "/usr/local/lib/python3.9/dist-packages/pynput/_util/init.py", line 76, in backend
Jan 31 20:33:00 proxmox python3[149058]: raise ImportError('this platform is not supported: {}'.format(
Jan 31 20:33:00 proxmox python3[149058]: ImportError: this platform is not supported: ('failed to acquire X connection: Bad display name ""', DisplayNameError(''))
Jan 31 20:33:00 proxmox python3[149058]: Try one of the following resolutions:
Jan 31 20:33:00 proxmox python3[149058]: * Please make sure that you have an X serve

usage area

Hello

I have a question of use does ln link work on Debian 10 or 11 machine? (example proxmox or proxmox virtual machine)

If yes I have a failure on the command pip3 install -U lnxlink and how to fix this?

image

Upower better results

Describe the problem
Bluetooth Battery module doesn't show only the bluetooth percentage. It only finds the 1st occurrence of percentage and returns this number.

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • Version 2023.2.0

Additional context
Using jc we can get more information about each device and the result should be returned as json with the device information.
Also the bluetooth_battery module should be renamed as battery.

This bug is based on the previous comments from the issue #39

Can't load addon: disk_usage

What type of installation are you running?

Desktop

Which Linux OS are you using?

Ubuntu 22.04

Which version of LNXLink has the issue?

2023.6.1

Describe the problem

I run the program(lnxlink -c ~/.lnxlinkrc) and then the error below shows up every refresh.

I think the problem is that it's trying to access some docker resource which it doesn't have permission to, but I don't think it makes sense to try to use this as a disk. I saw this with another Linux companion app I tried. I might be a good idea just to filter out docker disks completely.

Additional context

I also get this error, but it makes sense since I don't have an amd_gpu. However, it might be a good idea to detect this and just disable the module:

Can't load addon: amd_gpu
Traceback (most recent call last):
  File "/home/scott/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 77, in monitor_run
    pub_data = addon.getInfo()
  File "/home/scott/.local/lib/python3.10/site-packages/lnxlink/modules/amd_gpu.py", line 12, in getInfo
    first_gpu = pyamdgpuinfo.get_gpu(0)                        # we'll ignore extra GPUs
  File "pyamdgpuinfo/_pyamdgpuinfo.pyx", line 173, in pyamdgpuinfo._pyamdgpuinfo.get_gpu
  File "pyamdgpuinfo/_pyamdgpuinfo.pyx", line 228, in pyamdgpuinfo._pyamdgpuinfo.get_gpu
RuntimeError: GPU id 0 not found

Happy to file this as a separate issue if you'd like.

Configuration

mqtt:
  prefix: lnxlink
  clientId: DESKTOP-Linux
  statsPrefix: monitor/stats
  server: 10.0.0.223
  port: 1883
  auth:
    user: mosquitto_broker_user
    pass: wasd159731
  discovery:
    enabled: true
  lwt:
    enabled: true
    qos: 1
    retain: true
    connectMsg: 'ON'
    disconnectMsg: 'OFF'
update_interval: 5
modules: null

Logs

FYI journalctl --user -u lnxlink -n 300 --no-pager gives no output, but here are just the logs from the terminal after running the application:

Can't load addon: disk_usage
Traceback (most recent call last):
  File "/home/scott/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 77, in monitor_run
    pub_data = addon.getInfo()
  File "/home/scott/.local/lib/python3.10/site-packages/lnxlink/modules/disk_usage.py", line 17, in getInfo
    disk_stats = psutil.disk_usage(disk.mountpoint)
  File "/home/scott/.local/lib/python3.10/site-packages/psutil/__init__.py", line 2000, in disk_usage
    return _psplatform.disk_usage(path)
  File "/home/scott/.local/lib/python3.10/site-packages/psutil/_psposix.py", line 175, in disk_usage
    st = os.statvfs(path)
PermissionError: [Errno 13] Permission denied: '/var/lib/docker/overlay2/14c88c96744bdbce6237ffb04b1cbf60b881de57a87f35734df543f110100c22/diff'

meson-python: error: Could not find meson version 0.63.3 or newer, found 0.61.2

What type of installation are you running?

Desktop

Which Linux OS are you using?

Ubuntu 22.04

Which version of LNXLink has the issue?

2023.6.1

The problem

Went through the most recent installation docs and came across this error. Not sure what else to mention, but here's some potentially helpful version information:

$ uname -a
Linux scott-desktop-linux 5.15.0-73-generic #80-Ubuntu SMP Mon May 15 15:18:26 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ python3 --version
Python 3.11.0rc1
$ pip3 --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

Logs

$ pip3 install -U lnxlink
Defaulting to user installation because normal site-packages is not writeable
Collecting lnxlink
  Using cached lnxlink-2023.6.1-py3-none-any.whl (28 kB)
Collecting dbus-python>=1.3.2
  Using cached dbus-python-1.3.2.tar.gz (605 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [3 lines of output]

      meson-python: error: Could not find meson version 0.63.3 or newer, found 0.61.2
      meson-python: error: .
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Is there a way to know that my laptop is turned off?

I have lnxlink on my dev laptop. When I shut the laptop down, HA remembers the previous state that lnxlink reported for all of my entities, and they don't go unavailable even after several days. For example, the idle time on my laptop has been "3" ever since I shut it down.

I'm trying to create a template sensor for whether or not I'm currently using my laptop, but so far I can't figure out how to make it accurate.

So far, I've come up with:

{{ (has_value('sensor.dev_laptop_idle') and 
      (now() | as_local | as_timestamp - states.sensor.dev_laptop_idle.last_changed | as_local | as_timestamp < 120) and 
      (is_state('sensor.dev_laptop_idle', 'OFF') or (states('sensor.dev_laptop_idle') | int) <= 600)) }}

However even that causes issues, because after restarting HA, the last_changed timestamp updates to the current time, and it then says I'm using my laptop for at least the next 120 seconds.

Is there any way to have an MQTT entity from lnxlink that goes unavailable when it stops receiving updates so that I can detect when it's no longer receiving data from lnxlink more accurately?

Side note: Is it a bug that when idle time is 0, Home Assistant reports the state as OFF?

Computer as a smart TV

I think if the computer is a dummy tv for home assistant could be better because the Google home app recognize it like one device and not multiple switches.

In the technical notes the repo describe how to make a custom sensor but I didn't find a way to make this.

cant systemctl enable it

Sorry to bother but im pulling my hairs out... I cant figure out how to get this work.
I install with your sequence of commands and it works, but i cant make it work via systemd, i try via sudo systemctl enable lnxlink and throws this message
Failed to enable unit: Unit /run/systemd/generator.late/lnxlink.service is transient or generated.
When i start it via sudo lnxlink -c config.yaml
it says SystemD service not found or it's not running and starts to work, but as soon as i stop it... maybe its something related with systemd, but i can use systemctl with other services and they work (i dont know too much about this topic)

Im trying lots of things but nothing works,
Can someone help me?
Thanks!

Systemctl config generated incorrectly?

Describe the problem
It seems that if during the initial configuration i choose to create a system-wide start-up script (i dont remember how exactly it was worded, but it was one of the first questions), lnxlink generates a systemctl config pointing to lnxlink at /usr/local/bin/lnxlink, but the lnxlink is still located in user's home folder, therefore lnxlink doesnt start.

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu 22.04] Mint 21
  • Version [e.g. 2022.10.3] 2022.11.2

Logs

dinth@dinth-desktop-linux:~$ systemctl status lnxlink
× lnxlink.service - LNXLink
     Loaded: loaded (/etc/systemd/system/lnxlink.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2022-11-05 11:40:56 GMT; 5h 0min ago
    Process: 1640 ExecStart=**/usr/local/bin/lnxlink** -c /home/dinth/config.yaml (code=exited, status=203/EXEC)
   Main PID: 1640 (code=exited, status=203/EXEC)
        CPU: 518us

Nov 05 11:40:56 dinth-desktop-linux systemd[1]: lnxlink.service: Scheduled restart job, restart counter is at 5.
Nov 05 11:40:56 dinth-desktop-linux systemd[1]: Stopped LNXLink.
Nov 05 11:40:56 dinth-desktop-linux systemd[1]: lnxlink.service: Start request repeated too quickly.
Nov 05 11:40:56 dinth-desktop-linux systemd[1]: lnxlink.service: Failed with result 'exit-code'.
Nov 05 11:40:56 dinth-desktop-linux systemd[1]: Failed to start LNXLink.

dinth@dinth-desktop-linux:~$ whereis lnxlink
**lnxlink: /home/dinth/.local/bin/lnxlink**

Feature Request: Laptop Battery

Info about laptop battery percentage

# cat /sys/class/power_supply/BAT1/capacity
99
# cat /sys/class/power_supply/BAT1/status
Charging

JSON result was not a dictionary

Describe the problem
Home Assistant is throwing JSON warnings while parsing lnxlink messages

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu 22.04] Mint 21.1
  • Version [e.g. 2022.10.3] 2022.11.4

Logs

2022-12-21 09:05:02.418 WARNING (MainThread) [homeassistant.components.mqtt.mixins] JSON result was not a dictionary
2022-12-21 09:05:02.433 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received retained message on lnxlink/dinth-linux-desktop/monitor/stats/memory/usage: b'85.0'
2022-12-21 09:05:02.439 WARNING (MainThread) [homeassistant.components.mqtt.mixins] JSON result was not a dictionary
2022-12-21 09:05:02.443 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received retained message on lnxlink/dinth-linux-desktop/monitor/stats/network/upload: b'0.04'
2022-12-21 09:05:02.448 WARNING (MainThread) [homeassistant.components.mqtt.mixins] JSON result was not a dictionary
2022-12-21 09:05:02.454 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received retained message on zigbee2mqtt/Kitchen window shock sensor 2/availability: b'online'
2022-12-21 09:05:02.465 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received retained message on lnxlink/dinth-linux-desktop/monitor/stats/network/download: b'0.15'
2022-12-21 09:05:02.475 WARNING (MainThread) [homeassistant.components.mqtt.mixins] JSON result was not a dictionary

Open Path/URL

Could you possibly add the ability to open paths and URLs? Thanks.

Command not found

I installed and everything went ok, but when I try to start the service says that the command is not found.

Command:
systemctl --user start lnxlink
Output:
Failed to start lnxlink.service: Unit lnxlink.service not found.
Thanks in advance

Can't load addon: nvidia_gpu

Describe the problem
When I run lnxlink -c config.yaml I get the error Can't load addon: nvidia_gpu

LNXlink 2023.4.0 started: 3.10.6
Successfully loaded addon: xdg_open
Successfully loaded addon: bash
Successfully loaded addon: cpu
Successfully loaded addon: restart
Successfully loaded addon: battery
Successfully loaded addon: network_upload
Successfully loaded addon: memory
Successfully loaded addon: suspend
Successfully loaded addon: update
Successfully loaded addon: screen_onoff
Successfully loaded addon: idle
Successfully loaded addon: disk_usage
Successfully loaded addon: nvidia_gpu
Successfully loaded addon: sys_updates
Successfully loaded addon: camera_used
Successfully loaded addon: media
Successfully loaded addon: keep_alive
Successfully loaded addon: send_keys
Successfully loaded addon: notify
Successfully loaded addon: shutdown
Successfully loaded addon: required_restart
Successfully loaded addon: microphone_used
Successfully loaded addon: webcam
Successfully loaded addon: network_download
Connected to MQTT with code 0
Can't load addon: nvidia_gpu
Traceback (most recent call last):
  File "/home/r14n/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 62, in monitor_run
    pub_data = addon.getInfo()
  File "/home/r14n/.local/lib/python3.10/site-packages/lnxlink/modules/nvidia_gpu.py", line 12, in getInfo
    stdout = subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'nvidia-smi'
Can't load addon: nvidia_gpu
Traceback (most recent call last):
  File "/home/r14n/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 62, in monitor_run
    pub_data = addon.getInfo()
  File "/home/r14n/.local/lib/python3.10/site-packages/lnxlink/modules/nvidia_gpu.py", line 12, in getInfo
    stdout = subprocess.run(
  File "/usr/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'nvidia-smi'

Desktop (please complete the following information):

  • OS: Pop_OS
  • Version Pop!_OS 22.04 LTS

Additional context
I don't have Nvidia, how to disable looking for it? I have intel integrated Mesa Intel® Graphics (ADL GT2)

Configuration
Provide the configuration file, remove any sensitive info that might exist:

mqtt:
  prefix: lnxlink
  clientId: DESKTOP-Linux
  statsPrefix: monitor/stats
  server: 192.168.100.3
  port: 1883
  auth:
    user: XXXXXXXXXXXXXX
    pass: XXXXXXXXXXXXXX
  discovery:
    enabled: true
  lwt:
    enabled: true
    qos: 1
    retain: true
    connectMsg: 'ON'
    disconnectMsg: 'OFF'
update_interval: 5
modules: null

Shutdown Doesn't seem to work

Describe the problem

Using home assistant switch doesn't turn off nuc.
I can see it sent the message per mqtt (info) however it didn't do anything. For some reason my logs are not showing anything since August 4th when I attempted a restart command through mqtt (not using Discovery) and it didn't work.

Here's what I had for that

Aug 04 12:07:18 ubuntu systemd[1434880]: Stopping LNXLink...
Aug 04 12:07:19 ubuntu python3[1435298]: Successfully loaded addon: cpu
Aug 04 12:07:19 ubuntu python3[1435298]: Successfully loaded addon: memory
Aug 04 12:07:19 ubuntu python3[1435298]: Successfully loaded addon: network
Aug 04 12:07:19 ubuntu python3[1435298]: Successfully loaded addon: restart
Aug 04 12:07:19 ubuntu python3[1435298]: Successfully loaded addon: shutdown
Aug 04 12:07:19 ubuntu python3[1435298]: LNXLink started
Aug 04 12:07:19 ubuntu python3[1435298]: Connected to MQTT with code 0
Aug 04 12:07:19 ubuntu python3[1435298]: Message received: restart
Aug 04 12:07:19 ubuntu python3[1435298]: String could not be converted to JSON
Aug 04 12:07:19 ubuntu python3[1435298]: Message received: restart
Aug 04 12:07:19 ubuntu python3[1435298]: String could not be converted to JSON
Aug 04 12:07:19 ubuntu python3[1435298]: LNXLink stopped by user
Aug 04 12:07:19 ubuntu python3[1435298]: Disconnected from MQTT.
Aug 04 12:07:19 ubuntu systemd[1434880]: Stopped LNXLink.
Aug 04 12:07:19 ubuntu systemd[1434880]: lnxlink.service: Consumed 6.670s CPU time.

Running Ubuntu server.

What to do with update notifications

I'm not sure if this is a bug or just a lack of understanding about how this is supposed to work.

I have a Home Assistant automation that sends notifications to my phone when any update is available. The notification lets me start the update, or I can also go to the Home Assistant UI and start the update from Settings like normal.

Every day I see notifications on my phone for new lnxlink versions available, but the update isn't listed in the HA user interface. It's like it disappears shortly after appearing, even though it was not actually updated.

I've tried hitting the Update button from the phone notification, but since the update entity no longer appears in HA, I'm guessing that's why it doesn't work.

So I guess my question is whether or not this is the expected behavior? If there is an updatere available, shouldn't the update entity stay in Home Assistant until it's dismissed or updated?

As a secondary question, should I actually be able to install the update to lnxlink from HA? That would be incredible, but thus far the only way I can get it to actually update is manually running pip install --upgrade lnxlink from the laptop I'm running it on.

Thanks so much for the assistance!

Idle module - no mutter module

Describe the problem
Hi. I have just upgraded lnxlink from 2022.10.? to 2022.11.2 and run into an issue when configuring everything via "lnxlink -c config.yaml".

Successfully loaded addon: shutdown
Successfully loaded addon: restart
Successfully loaded addon: send_keys
Successfully loaded addon: notify
Successfully loaded addon: cpu
Successfully loaded addon: memory
Successfully loaded addon: network_upload
Successfully loaded addon: network_download
Successfully loaded addon: media
Successfully loaded addon: microphone
Successfully loaded addon: idle
Successfully loaded addon: bluetooth_battery
Successfully loaded addon: screen_onoff
Connected to MQTT with code 0
Can't load addon: idle
Traceback (most recent call last):
  File "/home/dinth/.local/lib/python3.10/site-packages/lnxlink/__main__.py", line 54, in monitor_run
    pub_data = addon.getInfo()
  File "/home/dinth/.local/lib/python3.10/site-packages/lnxlink/modules/idle.py", line 11, in getInfo
    idle_sec = monitor.get_idle_time()
  File "/usr/local/lib/python3.10/dist-packages/idle_time/__init__.py", line 87, in get_idle_time
    reply = self.connection.send_and_get_reply(self.message)
  File "/usr/local/lib/python3.10/dist-packages/jeepney/integrate/blocking.py", line 78, in send_and_get_reply
    return future.result()
  File "/usr/local/lib/python3.10/dist-packages/jeepney/integrate/blocking.py", line 33, in result
    raise value
jeepney.wrappers.DBusErrorResponse: [org.freedesktop.DBus.Error.ServiceUnknown] ('The name org.gnome.Mutter.IdleMonitor was not provided by any .service files',)
Can't load addon: idle

The above error keeps repeating itself.

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu 22.04] Mint 21
  • Version [e.g. 2022.10.3] 2022.11.2

Additional context
I think that i managed to sort it out by removing "idle" module from the config file, but it would be nice to have this error handled in a better way, especially if idle module is enabled by default.

Home Assistant/MQTT not receiving any data (first time setup)

Default config, get this when I try to manually run after didn't work with the stock procedure. The last error repeats over and over.

Successfully loaded addon: cpu
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Error with module: media
Traceback (most recent call last):
  File "/opt/lnxlink/modules/__init__.py", line 15, in <module>
    addons = getattr(import_module(f"{__name__}.{module_name}"), 'Addon')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/lnxlink/modules/media.py", line 4, in <module>
    import alsaaudio
ModuleNotFoundError: No module named 'alsaaudio'
Successfully loaded addon: memory
Successfully loaded addon: network
Successfully loaded addon: notify
Successfully loaded addon: restart
Successfully loaded addon: send_keys
Successfully loaded addon: shutdown
LNXLink started
Connected to MQTT with code 0
Exception in thread Thread-1 (_thread_main):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
Can't load addon: media
  File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 3591, in _thread_main
Traceback (most recent call last):
  File "/opt/lnxlink/run.py", line 44, in monitor_run
    addon = self.Addons[service]
KeyError: 'media'
    self.loop_forever(retry_first_connection=True)
  File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 1756, in loop_forever
    rc = self._loop(timeout)
  File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 1164, in _loop
    rc = self.loop_read()
  File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 1556, in loop_read
    rc = self._packet_read()
  File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 2439, in _packet_read
    rc = self._packet_handle()
  File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 3039, in _packet_handle
    return self._handle_connack()
  File "/usr/lib/python3.10/site-packages/paho/mqtt/client.py", line 3138, in _handle_connack
    on_connect(
  File "/opt/lnxlink/run.py", line 95, in on_connect
    self.setup_discovery()
  File "/opt/lnxlink/run.py", line 147, in setup_discovery
    addon = self.Addons[service]
KeyError: 'media'
Can't load addon: media
Traceback (most recent call last):
  File "/opt/lnxlink/run.py", line 44, in monitor_run
    addon = self.Addons[service]
KeyError: 'media'
Can't load addon: media
Traceback (most recent call last):
  File "/opt/lnxlink/run.py", line 44, in monitor_run
    addon = self.Addons[service]

install problem

onDebian (LMDE 5) i installed dependencies.
pip3 install -U lnxlink doesnt work, but python3 -m pip install -U lnxlink.

but then i have errors:

$ python3 lnxlink -c config.yaml
python3: can't open file '/home/xxx/lnxlink': [Errno 2] No such file or directory

what can i do?

Home Assistant integration: device class NONE for sensor.disk_usage

Hello,

Since updating Home Assistant to 2023.3 I am receiving the following error message in the HA log file. I assume it has something to do with the MQTT message, but unsure how to correct the issue. Thank you.

Sensor sensor.disk_usage_ubuntu has device class None, state class None and unit thus indicating it has a numeric value; however, it has the non-numeric value: False (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22

Feature request: Sleep/suspend controls

Describe the problem

OS Version

Linux Mint 21
LNXLink version

9c7e3fb

I would like to request a feature of enabling/disabling sleep on the machine
(it can be done by the following commands:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

or alternatively by making lnxlink service inhibit sleep, simple example: https://github.com/bulletmark/sleep-inhibitor
This can be presented as a switch in Home Assistant.
On the top of that, it would be nice to have Sleep/Suspend commands which would work in a same way as Shutdown command right now.

Not Sending MQTT Messages After Install

I installed this on a nuc running ubuntu server.
Here's my configuration. I assume similar to iotlink this is meant to send messages constantly, however I restarted the service a few times and nothing happened.

Initially I thought it could be because I have another server that uses iotlink and the same prefix but changing that and restarting didn't help either.

mqtt:
  prefix: iotlink/workgroupp
  clientId: ubuntu-nuc
  statsPrefix: ubuntu-monitor/stats
  server: 192.168.4.32
  port: '1883'
  auth:
    user: user
    pass: pw
  discovery:
    enabled: true
  lwt:
    enabled: true
    qos: 1
    retain: true
    connectMsg: 'ON'
    disconnectMsg: 'OFF'
control:
- shutdown
- restart
- send-keys
- run
- notify
- media
monitoring:
- cpu
- memory

Check Package Manager for system updates

Describe the solution you'd like
It would be ace if LNXLink could you show whether systems updates are available (yum/apt).

Additional context
No updates are available:

  • APT (> 2): apt list --upgradable | wc -l

If anyone knows the other package managers how to get the updates, let me know.

Feature Request: Monitor On/Off

Control:

# Turn off display
$ sleep 1 && xset dpms force off
# Turn on display
$ sleep 1 && xset dpms force on

Query:

$ xset q 
.
.
.
DPMS (Energy Star):
  Standby: 0    Suspend: 0    Off: 0
  DPMS is Enabled
  Monitor is On

Client Id in sensor/switch name in home assistant

Could the client id be includes in all the auto discovered device names in home assistant?

I'am using your great app on multiple servers and i'am having troubels keeping the devices apart.
The naming is like:

  • sensor.cpu_usage
  • sensor.cpu_usage_2

It would be nice if it could be:
sensor.<>cpu_usage for instance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.