hass-opnsense icon indicating copy to clipboard operation
hass-opnsense copied to clipboard

Feature request: Thermal Sensor Data

Open roadbikemike opened this issue 1 year ago • 11 comments

I see someone had asked about gathering thermal data in Discussions but do not see an open Issue. Would be great to have CPU thermal data sent to Home Assistant. Would like to do some automation around this metric and disappointed to not see it there.

roadbikemike avatar Apr 21 '23 12:04 roadbikemike

yes very cool !!

syberx avatar May 25 '23 10:05 syberx

I’ll get to it at some point. If you want to find out where the data is available in the api that would help preempt my research when I get a little time.

travisghansen avatar May 25 '23 12:05 travisghansen

I poked around some of the documented Core API functions and unfortunately could not find much regarding thermal data. However, I may have missed something. Looking at the OPNsense dashboard, the thermal data is populated using this URL:

https://opnsense.localdomain/widgets/api/get.php?load=temperature

Which returns:

{"system":"OPNsense","plugins":["interfaces","system","temperature"],"data":{"temperature":[{"device":"dev.cpu.0.temperature","device_seq":"0","temperature":"48.7","type":"core","type_translated":"Core"},{"device":"dev.cpu.1.temperature","device_seq":"1","temperature":"48.7","type":"core","type_translated":"Core"},{"device":"hw.acpi.thermal.tz0.temperature","device_seq":"0","temperature":"47.6","type":"zone","type_translated":"Zone"}]}}

Perhaps this is enough?

roadbikemike avatar May 25 '23 12:05 roadbikemike

Perhaps. I’ll look deeper at some point. Just don’t have much time to put to the project currently :(

travisghansen avatar May 25 '23 12:05 travisghansen

Totally understand and thanks for getting back on this! Much appreciated. I will keep poking to see if there is something I am missing for thermal data in the documented API. Although, that URL does seem to be part of the API, but under widgets (which is not documented).

roadbikemike avatar May 25 '23 12:05 roadbikemike

There is an underlying ‘api’ in php land that they are almost certainly using. The way the integration is designed it gives complete access to all the underlying php libs/code as well. In this particular case it’s probably a better option to figure out what the endpoint is using and use that vs using the endpoint directly.

travisghansen avatar May 25 '23 13:05 travisghansen

From what I can tell, this is the only way to gather thermal data programmatically at this time:

https://github.com/opnsense/core/blob/5d5e9579415c70d62e31876e4c649467f0db22b2/src/www/widgets/api/get.php

Which then references:

https://github.com/opnsense/core/blob/5d5e9579415c70d62e31876e4c649467f0db22b2/src/www/widgets/api/plugins/temperature.inc

Looks like temperature.inc executes the actual command via configd_run which returns the thermal metrics.

There is a comment in get.php which states:

Simple wrapper to retrieve data for widgets using legacy code.

Perhaps they have not moved the thermal data into the mainstream/underlying API yet.

roadbikemike avatar May 25 '23 13:05 roadbikemike

Right, but the way the integration works you can just tap into the latter directly.

travisghansen avatar May 25 '23 14:05 travisghansen

Any chance this might happen?

larhedse avatar Jul 26 '23 16:07 larhedse

Any chance this might happen?

Yep, that would be a useful feature as monitoring the SBC that runs OPNsense (at least in my case) is something I need to keep an eye on. There is no fans on that SBC and the room is shared with other warm stuff. I do it indirectly at the moment via my NAS temp but would be a nice quality of life implementation.

3dRikal avatar Nov 01 '23 20:11 3dRikal

up

PilaScat avatar May 16 '24 20:05 PilaScat