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

How to Create Sensors #9

Open
lmath56 opened this issue Sep 25, 2022 · 6 comments
Open

How to Create Sensors #9

lmath56 opened this issue Sep 25, 2022 · 6 comments

Comments

@lmath56
Copy link

lmath56 commented Sep 25, 2022

Hi,

I am having some trouble creating Sensors.
I have followed the steps and I can see the below:
image

I would like to create sensors for different things such as system uptime, how many dhcp leases, public ip address, etc.
I've done a bit of research but haven't had much luck.

I was able to use the openwrt.reboot service to restart OpenWRT. Can I possibly parse the output from openwrt.exec command to a sensor?

Thanks!

@kaciker
Copy link

kaciker commented Jan 16, 2023

Same question

@Asiak3
Copy link

Asiak3 commented Jan 17, 2023

same

@kvj
Copy link
Owner

kvj commented Jan 18, 2023

Hey,

Can I possibly parse the output from openwrt.exec command to a sensor?

In theory - yes. But it's not implemented. The standard output is available as part of the Ubus call response, but it should be somehow exposed to 3rd-party scripts or automatons.

The easy way - emit Hass event after each openwrt.exec call with the output and exit code, but you will need to listen to that event using Hass automation, parse the output and update one of your helper sensors for that.

Another approach - add and update custom OpenWrt sensor with output of openwrt.exec response. With this approach, you can create template sensors and parse output. A bit easier to support your custom code (one template sensors vs. helper + automation), but more difficult to support multiple commands

@blackie333
Copy link

Considering this integration for monitoring 2 openlumi devices (openwrt in client-wifi mode) with some sensors (lamp, button switch, luminance sensor) and Zigbee router integrated.
Sometimes (after HA restart) related HA entities got stuck with no values and I have to reboot both openlumi devices.
I would like to use the reboot service in automation but also would like to use an uptime sensor.

Would it be possible to explain in more details how to create an uptime sensor in HA (via template sensor in config.yaml), based on the default openwrt configuration?
Thanks in advance

@kvj
Copy link
Owner

kvj commented Feb 15, 2023

Would it be possible to explain in more details how to create an uptime sensor in HA (via template sensor in config.yaml)

There's no way, currently. You can exec any program using the service the integration provides, but its standard output isn't available. That should be implemented first

@bkbartk
Copy link

bkbartk commented Oct 13, 2023

I would like to know also,
but when I try

service: openwrt.exec
data:
  command: system board
target:
  device_id: b8c531xxxxxxx84291020

or some variation, I only get permission errors.
openwrt.reboot works
I think I messed up some permissions, or I don't know what to fill for command.

edit:
sorry,
missed this part

There's no way, currently. You can exec any program using the service the integration provides, but its standard output isn't available. That should be implemented first

still I have some permissions issues, but when I can't get the result, it won't matter

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

6 participants