justme-1968 / homebridge-fhem

a fhem platform plugin for homebridge
https://wiki.fhem.de/wiki/Homebridge_einrichten
79 stars 16 forks source link

StatusLowBattery always 1 #40

Open drstil opened 6 years ago

drstil commented 6 years ago

I'm using the current homebridge-fhem version with a temperature sensor. The config in fhem is done like this:

define WohnzimmerWetter pilight_temp alecto_ws1700 11 attr WohnzimmerWetter IODev pilight attr WohnzimmerWetter genericDeviceType thermometer

The sensor has the attribute "battery" which has "0" when battery level is low and "1" if battery level is normal. But in Apple Home I always got a "battery level low" even if battery has value "1".

homebridge log:

WohnzimmerWetter-battery: 1 caching: BatteryLevel: 1 (as number; from '1') caching: StatusLowBattery: 1 (as number; means BATTERY_LEVEL_LOW; from '1')

Normally I do not have to make my own mapping, because it is done in index.js:1419.

So it seems that battery:1 is not detected correctly. If a set my own homebridge mapping, it has the same issue.

attr WohnzimmerWetter homebridgeMapping StatusLowBattery=battery,values=0:BATTERY_LEVEL_LOW;1:BATTERY_LEVEL_NORMAL caching: StatusLowBattery: 1 (as number; means BATTERY_LEVEL_LOW; from '0') caching: StatusLowBattery: 1 (as number; means BATTERY_LEVEL_LOW; from '1')

The mapping is correctly as I have it in the homebridge log.

If I change my mapping like this, I got battery level normal.

StatusLowBattery=battery,values=1:BATTERY_LEVEL_LOW;0:BATTERY_LEVEL_NORMAL

caching: StatusLowBattery: 0 (as number; means BATTERY_LEVEL_NORMAL; from '0') caching: StatusLowBattery: 0 (as number; means BATTERY_LEVEL_NORMAL; from '1')

Do you need more information?

Thank you and best!

volschin commented 6 years ago

It works as designed by HomeKit. You can see here https://developer.apple.com/documentation/homekit/hmcharacteristictypestatuslowbattery

To change the mapping like done in your last action is the right way to handle the incompatible behaviour of your device.

drstil commented 6 years ago

Yes but neither with my own mapping nor with the setting of homebridge (index.js line 1419) it works correctly. As you see below my own mapping, it does not matter if the battery status of the device is 0 or 1, the status low battery is always the value form 0 to whatever.

volschin commented 6 years ago

What versions of Homebridge and Homebridge-fhem do you use? I see neither timestamp nor [FHEM] tag in your log output.

drstil commented 6 years ago

Removed for clarity. homebridge-fhem@0.3.7, homebridge@0.4.33.

RichiG88 commented 4 years ago

I have the same issue with homebridge-fhem@0.5.16, homebridge@0.4.53 and node@10.19.0

FHEM-device: define Wetterstation pilight_temp tfa 11

Output from hb-service logs:

2020-03-27 03:47:28 caching: Wetterstation-battery: 0
[2020-3-27 3:47:28 AM] [FHEM]     caching: BatteryLevel: 0 (as number; from '0')
[2020-3-27 3:47:29 AM] [FHEM]     caching: StatusLowBattery: 1 (as number; means BATTERY_LEVEL_LOW; from '0')

The battery is actually low, but if FHEM receives a "battery":1, the StatusLowBattery is still 1 even if i try to remap it using homebridgeMapping.

justme-1968 commented 4 years ago

please show your mapping

RichiG88 commented 4 years ago

The output above was made without a mapping. I have tried different mappings in the past but I don’t think they were working. For example: StatusLowBattery=battery,values=0:BATTERY_LEVEL_LOW;1:BATTERY_LEVEL_NORMAL ——————————————- Auf Deutsch ist es wahrscheinlich einfacher, Also wie gesagt, ich habe in der Vergangenheit mehrfach mit dem Mapping experimentiert, konnte aber nie eine Änderung feststellen. Nun ist die Batterie im Temperatursender tatsächlich schwach geworden und sendet eine 0 und trotzdem wird in homebridge-fhem eine 1 draus, obwohl kein Mapping genutzt wurde.

volschin commented 4 years ago

Tut doch aber genau das, was Du ihm gesagt hast. Das ist ein TRUE/FALSE. Und damit heißt in HomeKit 1=BATTERY_LEVEL_LOW, dass die Batterie schwach ist.

Dein Mapping sagt ihm Wert 0 in FHEM= Wert 1 in Homekit. Das zeigt auch das Logging.

RichiG88 commented 4 years ago

Das Logging wurde aber ohne Mapping erstellt und trotzdem wird eine 0 in eine 1 geändert. In der pilight Weboberfläche wird mir im Normalfall eine grüne Batterie angezeigt, wenn pilight battery:1 empfängt. In HomeKit bedeutet die 1 dann aber BATTERY_LEVEL_LOW und ich erhalte eine Batterie-Warnung. Nun empfängt pilight battery:0 und zeigt eine rote Batterie, aber in HomeKit kommt wiederum eine 1 an. Wie gesagt, alles ohne Mapping. Wenn HomeKit eine gegensätzliche Logik zu pilight hat, müsste es ja dann auf BATTERY_LEVEL_NORMAL springen, was es aber nicht macht.

justme-1968 commented 4 years ago

bitte poste mal die zum mapping gehörende log ausgabe

RichiG88 commented 4 years ago

Die Batterie hat sich wieder erholt, ist wahrscheinlich durch die kalten Temperaturen draußen in die Knie gegangen, also pilight empfängt wieder ein battery:1.

Hier der Log mit mapping:

[2020-3-27 12:38:08 PM] [FHEM] homebridgeMapping: StatusLowBattery=battery,values=0:BATTERY_LEVEL_LOW;1:BATTERY_LEVEL_NORMAL
[2020-3-27 12:38:08 PM] [FHEM] Wetterstation is thermometer
[2020-3-27 12:38:08 PM] [FHEM] Wetterstation has
[2020-3-27 12:38:08 PM] [FHEM]   BatteryLevel [battery]
[2020-3-27 12:38:08 PM] [FHEM]   StatusLowBattery [battery]
[2020-3-27 12:38:08 PM] [FHEM]   CurrentTemperature [temperature]
[2020-3-27 12:38:08 PM] [FHEM]   CurrentRelativeHumidity [humidity]
  2020-03-27 12:38:08 caching: Wetterstation-battery: 1
[2020-3-27 12:38:08 PM] [FHEM]     caching: BatteryLevel: 1 (as number; from '1')
[2020-3-27 12:38:08 PM] [FHEM]     caching: StatusLowBattery: 1 (as number; means BATTERY_LEVEL_LOW; from '1')
...
[2020-3-27 12:38:08 PM] [FHEM] Initializing platform accessory 'Wetterstation'...
[2020-3-27 12:38:08 PM] [FHEM] creating services for Wetterstation
[2020-3-27 12:38:08 PM] [FHEM]   information service for Wetterstation
[2020-3-27 12:38:08 PM] [FHEM]     manufacturer, model and serial number characteristics for Wetterstation
[2020-3-27 12:38:08 PM] [FHEM]     name (siriName) characteristic for Wetterstation
[2020-3-27 12:38:08 PM] [FHEM]   TemperatureSensor service for Wetterstation
HAP Warning: Characteristic 00000068-0000-1000-8000-0026BB765291 not in required or optional characteristics for service 0000008A-0000-1000-8000-0026BB765291. Adding anyway.
[2020-3-27 12:38:08 PM] [FHEM]     BatteryLevel characteristic for Wetterstation:battery
[2020-3-27 12:38:08 PM] [FHEM]     StatusLowBattery characteristic for Wetterstation:battery
[2020-3-27 12:38:08 PM] [FHEM]     CurrentTemperature characteristic for Wetterstation:temperature
HAP Warning: Characteristic 00000010-0000-1000-8000-0026BB765291 not in required or optional characteristics for service 0000008A-0000-1000-8000-0026BB765291. Adding anyway.
[2020-3-27 12:38:08 PM] [FHEM]     CurrentRelativeHumidity characteristic for Wetterstation:humidity
...
[2020-3-27 12:38:38 PM] [FHEM] query: StatusLowBattery for Wetterstation-battery
[2020-3-27 12:38:38 PM] [FHEM]   cached: 1 (as number; means BATTERY_LEVEL_LOW)
RichiG88 commented 4 years ago

Falls mein vorheriger Post missverständlich war, das Verhalten ist meiner Meinung nach immer noch fehlerhaft, da trotz des Mappings eine 1 an HomeKit übergeben wird. Ist mein Mapping so korrekt oder habe ich da einen Fehler gemacht?

justme-1968 commented 4 years ago

da funk der automatisch erkannte threshold dazwischen. ich weiss noch nicht genau warum.

setz mal StatusLowBattery=clear,battery,values=0:BATTERY_LEVEL_LOW;;1:BATTERY_LEVEL_NORMAL

RichiG88 commented 4 years ago

Sehr gut, vielen Dank.

[2020-3-28 6:52:25 PM] [FHEM] homebridgeMapping: StatusLowBattery=clear,battery,values=0:BATTERY_LEVEL_LOW;;1:BATTERY_LEVEL_NORMAL
[2020-3-28 6:52:25 PM] [FHEM] Wetterstation is thermometer
[2020-3-28 6:52:25 PM] [FHEM] Wetterstation has
[2020-3-28 6:52:25 PM] [FHEM]   BatteryLevel [battery]
[2020-3-28 6:52:25 PM] [FHEM]   CurrentTemperature [temperature]
[2020-3-28 6:52:25 PM] [FHEM]   CurrentRelativeHumidity [humidity]
[2020-3-28 6:52:25 PM] [FHEM]   StatusLowBattery [battery]
  2020-03-28 18:52:25 caching: Wetterstation-battery: 1
[2020-3-28 6:52:25 PM] [FHEM]     caching: BatteryLevel: 1 (as number; from '1')
  2020-03-28 18:52:25 caching: Wetterstation-temperature: 13.88
[2020-3-28 6:52:25 PM] [FHEM]     caching: CurrentTemperature: 13.88 (as number; from '13.88')
  2020-03-28 18:52:25 caching: Wetterstation-humidity: 31
[2020-3-28 6:52:25 PM] [FHEM]     caching: CurrentRelativeHumidity: 31 (as number; from '31')
[2020-3-28 6:52:25 PM] [FHEM]     caching: StatusLowBattery: 0 (as number; means BATTERY_LEVEL_NORMAL; from '1')

Jetzt wird es auch in HomeKit richtig angezeigt.