AVM FritzBox Temperature

Hi!
thx for the great integration! Is it possible to add Temperature to the Integration?

right now I use this as a sensor:

curl -s "http://fritz.box/query.lua?CPUTEMP=cpu:status/StatTemperature&sid=XXXXXXX" | grep -Po '(?<=":").*?(?=,)'

Hi, I’m interested too to retrieve CPU temp of fritzbox.
While waiting for a new feature in the integration, can you pls detail how you get it with the curl command? In particular, how do you get the SID and which is the code for the sensor. Thanks!

unfortunately the tr-064 api of the FritzBox does not provide such system details (see Schnittstellen für Entwickler | AVM Deutschland)

You can still use the undocumented HTTP API. That’s my attempt to provide temperature values in my custom version of the fritz integration:

def _retrieve_device_temperature(
    status: FritzStatus, last_value: int
) -> int:
    """Return temperature from device."""
    for sid in status.fc.http_interface._get_sid():
        if sid == None:
            continue
        with status.fc.session.get(f"{status.fc.address}:{status.fc.http_interface.remote_port}/query.lua", params={
            "CPUTEMP": "cpu:status/StatTemperature",
            "sid": sid
        }) as response:
            if response.status_code == HTTPStatus.OK:
                result = response.json()
                return result["CPUTEMP"].split(",")[0]
    return None

Not pretty and probably a bit unstable, but it’s working perfectly fine right now. The code is based on the implementation of the AHA-HTTP-Interface from the fritzconnection library.

When this get included into the fritzconnection library, than it is as easy to add it as sensors to the AVM Fritz!Box Tools integration in HA.

It doesn’t need to be included in fritzconnection, my code can be directly pasted in the integration as a sensor update method. Indeed I already did that in my custom version of the integration and it’s working flawlessly for over a month now.

based on the development checklist such functions has to be implemented into the library - especial when looking at your code, yes it works, but it touches internals of the library, which should not be done in the integrations code - therefore adding this feature to the lib first is the way to go

Okay I’ll create a pull request as soon as I have time.

1 Like

I’d love this integration as well and I’m not tech savvy enough for any custom integration. So I’d appreciate the inclusion of CPU Temp a lot!

Created a pull request at fritzconnection today: Add cpu_temp property to fritz status by 1RandomDev · Pull Request #232 · kbr/fritzconnection · GitHub