Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Battery level report in MQTT?

Battery level report in MQTT?

Scheduled Pinned Locked Moved Troubleshooting
4 Posts 2 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Johan
    wrote on last edited by
    #1

    Hi

    I have added battery level reporting for a temperature sensor. It sends that to a MQTT gateway connected to Openhab. I see the battery level report go from the sensor, to the gateway but then it looks sort of funny when I look at the MQTT message.
    I want to pick the message up in Openhab to get a status of the battery level there but I don't get Openhab to receive it.

    In the Serial monitor for the gateway it look like this:

    0;0;3;0;9;read: 20-20-0 s=255,c=3,t=0,pt=1,l=1,sg=0:95
    MyMQTT/20/255/V_

    I tried to read that value in Openhab, without success (It looks weird so I guess it's wrong) , with this item:

    Number Batteri_Kvar_Inne "Batteri kvar [%.1f %]" <battery> {mqtt="<[nuc:MyMQTT/20/255/V_:state:default]"}

    Anyone have experience from visualising the battery level on Openhab with MQTT and have any idea what's going on and how to pick it up in Openhab?

    /Johan

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Johan
      wrote on last edited by
      #2

      Update...

      I have figured out why the MQTT message looks strange. In the MyMQTT.h file there are an array that translates the variable type to the string that should be sent in the MQTT message. The value for the battery level I get from my sensor is 50 and that translation translates to "", and thus the message obviously becomes just V_.
      It is an easy fix to fix my message but maybe the whole translation table should be updated by someone who know more about all the various other variable types. As I am sort of new to MySensors, what is the proper way to get this fixed? Create an issue in Git?

      /Johan

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Johan
        wrote on last edited by
        #3

        Another update...

        Yesterday I switched to using the MQTTClientGateway from tomkxy's branch. It is acting as a MQTT client instead of as a broker, as I think it should. I mean, if you have installed Openhab and thinking of using MQTT instead of serial as communication I think installing a Mosquitto broker (for example) probably is not a big deal. :)
        There are obvious benefits to using a "real" broker in that you can have several clients subscribing to the messages at once. This also lets you monitor the messages sent through the broker.

        It works great and I now get all the values to Openhab without problems. It even runs on my UNO with the Ethernet shield, even though several persons have said the memory would not be sufficient. Thanks tomkxy!

        /Johan

        1 Reply Last reply
        0
        • T Offline
          T Offline
          TommySharp
          wrote on last edited by
          #4

          Hi Johan, I have been trying to get the MQTTClient gateway running a few months back but gave up..... Can you share the final sketch you used?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          29

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular