jheling / freeathome

Free@Home component for Home Assistant
114 stars 41 forks source link

Battery level of door/window sensor #203

Open NeoBlack opened 1 month ago

NeoBlack commented 1 month ago

Can you get the battery level (percent of level) for the door/window sensors? Free@Home self has no good battery level information. Most of the time, I don't recognize that the battery is low, and then I get a message from Free@Home that the device is offline. Yeah!!!

free@home shows the battery level and battery voltage in the device configuration:

Bildschirmfoto 2024-09-29 um 00 14 10

With the local API, I tried to get the value, but the response did not contain the battery data:

{
  "00000000-0000-0000-0000-000000000000": {
    "devices": {
      "ABBXXXXXXXXX": {
        "deviceReboots": "21",
        "floor": "01",
        "room": "03",
        "interface": "RF",
        "deviceId": "2042",
        "displayName": "Fenster Arbeitszimmer links",
        "unresponsive": false,
        "unresponsiveCounter": 0,
        "defect": false,
        "channels": {
          "ch0001": {
            "floor": "01",
            "room": "03",
            "displayName": "Fenster Arbeitszimmer links",
            "selectedIcon": "51",
            "functionID": "64",
            "inputs": {},
            "outputs": {
              "odp0000": {
                "pairingID": 53,
                "value": "0"
              },
              "odp0001": {
                "pairingID": 41,
                "value": "0"
              }
            },
            "parameters": {}
          }
        },
        "parameters": {
          "par0065": "0"
        }
      }
    }
  }
}

If this integration can provide this data, I could create automation to monitor and warn before the device goes offline.

jheling commented 1 month ago

Hi, i looked at you initial issue with the wireless window sensor, I see a batteryVoltage attribute in the free@home dump. Maybe we can use this?

NeoBlack commented 1 month ago

Yes, you are right. In the XML dump, I see the attributes batteryStatus="FF" batteryLow="false" and an attribute node:

<attribute name="batteryVoltage">2.98389</attribute>

I have no idea what the value FF means, and I can't find a percentage value for the battery in the XML dump. But at least two of the three values (batteryVoltage and batteryLow) are useful information.

derjoerg commented 1 month ago

Just two possibilities to think about (only a shot in the dark):

  1. Battery Percentage might be just calculated from Battery Voltage (so e.g. 3 = 100%, 2,9 = 97%, ...)
  2. The Battery Status is a hex representation of the Battery Percentage (so FF = 100%, FA = 98%)

But these are just guesses. I don't have such devices to test

NeoBlack commented 1 month ago

I tried to get a new dump from my door sensors, but with the new firmware, I can't find the monitor/dump view anymore. Where can I find it in the current firmware? Then, I could check different devices and validate the hex representation theory.