MQTT batterylevel reporting



  • Hi

    I've migrated from serial to mqtt. With the serial connection I got the sensors to report the batterylevel, but I can't get it to work with the MQTT GW.

    I've seen, that there's a "default" battery reporting line in MySensor.h

         void sendBatteryLevel(uint8_t level, bool ack);
    

    But how do I adapt that to mqtt?

    Can I just add the line at the end of the default temperature sensor loop?


  • Hero Member

    Because I'm lazy at soldering I only have one battery board so far that actually reports battery level, but for me the battery is coming through as

    MyMQTT/4/255/50 92
    

    Or whatever, "92" being the payload. I went into MyMQTT.cpp and changed the pertinent line to

    char V_50[] PROGMEM = "BATTERY_LEVEL";
    

    So it looks a bit prettier and easier to catch in Python. As for actually using that value with some controller / HA software that is another matter. I myself save it as a "user variable" in Domoticz (since many of the dummy sensors in Domoticz can't have a battery level apparently). That way I can have a long list all in one place of all battery levels and can sort it.

    What sort of controller do you use?



  • I'm using OpenHab as controller.

    It worked pretty good when i had a raspberry as a serial gateway reporting to Openhab, but now I've switched to a MQTT gateway on an UNO. That works fine for a few temp sensors, but i'm having serious trouble getting a 8-channel relay node to work. It works for about 1-2 hours then it stops responding 😞 Then i have to powercycle it, to get it running again.

    Currently the temp sensors report this:

    0;0;3;0;9;read: 1-1-0 s=255,c=3,t=0,pt=1,l=1:81
    

    for a battery reading (81%).


Log in to reply
 

Suggested Topics

11
Online

9.4k
Users

10.0k
Topics

104.3k
Posts