Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ubus system uptime sensor #15

Open
denisfrench opened this issue Aug 19, 2023 · 0 comments
Open

Implement ubus system uptime sensor #15

denisfrench opened this issue Aug 19, 2023 · 0 comments

Comments

@denisfrench
Copy link

I note the discussion around creating sensors here #9 , and also that commit aaddd2b implemented capture of the openwrt.exec service call stdout return on the event bus.

The resulting event from calling the /usr/bin/uptime command example from the readme is:

event_type: openwrt_exec_result
data:
  address: 192.168.1.1
  id: Ntgr-X4S-R7800
  command: /usr/bin/uptime
  code: 0
  stdout: |2
     09:50:44 up 3 days, 16:23,  load average: 0.21, 0.19, 0.16
origin: LOCAL
time_fired: "2023-08-18T23:50:44.891336+00:00"
context:
  id: 01H85GXXWV1VG59SAMTENB3HBH
  parent_id: null
  user_id: null

For those with a moderate amount of Home Assistant knowledge, it should therefore be possible to setup an automation to periodically call the openwrt.exec service (https://www.home-assistant.io/docs/automation/trigger/#time-pattern-trigger), and capture the output within a template trigger sensor (https://www.home-assistant.io/integrations/template/#trigger-based-template-binary-sensors-buttons-images-numbers-selects-and-sensors). I haven't tried it yet; capturing and reformatting the output looks a little tricky, but doable.

However I have confirmed that the terminal command ubus call system info | jsonfilter -e "@['uptime']" directly returns OpenWRT system uptime in seconds, and suggest that implementing this as a sensor within the integration is a more elegant and user friendly solution.

Thank you for your work on this in any case; it is already very useful in monitoring OpenWRT connectivity within Home Assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant