Announcement

Collapse
No announcement yet.

Need Help with JSON Tasmota Parsing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need Help with JSON Tasmota Parsing

    I've been really struggling with this one, I'm experimenting with integrating a few Sonoff relays to Homeseer via MQTT. The Sonoff devices are running the Tasmota firmware.

    I've got the relay function working perfectly with Homeseer, but whats got me confused is bringing in temperature data into Homeseer. Basically the Tasmota firmware sends all the telemetry data together into one MQTT topic formatted in JSON. I'm trying to take the single JSON string and separate it out into 5 different Homeseer virtual devices.

    here is the string that Tasmota sends to Homeseer:
    {"Time":"2017-12-07T23:22:18","AM2301":{"Temperature":82.0,"Humidity":5.8},"B MP280":{"Temperature":69.0,"Pressure":997.3},"TempUnit":"F"}

    i'm trying to get it into 5 virtual devices named: Time,Temp1,Humidity,Temp2,Pressure

    I have zero VB scripting knowledge, but from what i've read it seems i need the NewtonSoft DLL in my Homeseer directory. I don't know where to go from there as to writing the script.

    Would someone with more VB knowledge be able to help me out?
    Thanks,
    James
    Attached Files

    #2
    You should be able to use my Datascraper script to do this. The latest version allows you to parse virtual devices in addition to web pages and files for data.

    Download it from my site (click on my banner below) and install as per the docs. Replace the [Grab1] entry in the Jon00DataScraper.ini file with the following:

    Code:
    [Grab1]
    Path=1285
    TextFile=0
    Encoding=
    Username=
    Password=
    Options=
    UserAgent=
    Devicemode=2
    StripHTML=1
    Pattern1=(?s){"Time":"(.*?)","AM2301":{"Temperature":(.*?),"Humidity":(.*?)},"B MP280":{"Temperature":(.*?),"Pressure":(.*?)}
    DeviceName1=Time
    DeviceText1=[0]
    DeviceName2=Temp1
    DeviceText2=[1]°F
    DeviceValue2=[1]
    DeviceName3=Humidity
    DeviceText3=[2]%
    DeviceValue3=[2]
    DeviceName4=Temp2
    DeviceText4=[3]°F
    DeviceValue4=[3]
    DeviceName5=Pressure
    DeviceText5=[4]
    DeviceValue5=[4]
    Then run the script using the documentation to help you. If all is OK, you should get 5 devices created as shown below. You can add icons if you wish.....
    Attached Files
    Jon

    Comment


      #3
      Thanks for the info Jon,
      I got everything installed, ran the script with an event, it created the 5 new virtual devices, but I'm getting no data coming in. In the docs i see a reference to a Jon00DataScraperData.ini file, i don't appear to have that file anywhere, should that be auto-created or do i need to manually create it?

      I turned on the text file option and i get a grab1 file, the string seems to be coming into the script OK.

      Any ideas?
      Thanks,
      James
      Attached Files

      Comment


        #4
        Would you pleae post the actual Grab1.txt. I can use that to test here.
        Jon

        Comment


          #5
          I've just noticed that the board has added a space in the pattern definition (between the B and MP280).

          Try this:
          PHP Code:
          Pattern1=(?s){"Time":"(.*?)","AM2301":{"Temperature":(.*?),"Humidity":(.*?)},"BMP280":{"Temperature":(.*?),"Pressure":(.*?)} 
          Jon

          Comment


            #6

            Comment


              #7

              Comment


                #8
                Don't scrape it. That's lame. Use a script and a proper JSON library (Newtonsoft) to grab the keys you need.

                Look at the example I gave here:
                https://forums.homeseer.com/showthread.php?t=192367

                Comment


                  #9
                  Use the mcsMQTT (Michaels) plugin, does all of the parsing for you :-)
                  HS 2.2.0.11

                  Comment


                    #10
                    Originally posted by petez69 View Post
                    Use the mcsMQTT (Michaels) plugin, does all of the parsing for you :-)
                    It does? It can parse JSON directly?
                    HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                    Running on Windows 10 (64) virtualized
                    on ESXi (Fujitsu Primergy TX150 S8).
                    WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                    Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                    Comment


                      #11
                      Moskus

                      Go to the forum thread, the documentation is on the first post. See if it can do what you need...

                      https://forums.homeseer.com/showpost...03&postcount=1

                      I've got 2xPOWS, 3 basics with DS18B20s and AM2301s on them. Jsut made up a "Magichome" equivalent to drive an LED strip....mcsMQTT is aweseome with Tasmota

                      Cheers..Pete
                      Last edited by petez69; January 20, 2018, 06:09 AM.
                      HS 2.2.0.11

                      Comment


                        #12

                        Comment


                          #13
                          Bloody good isnt it :-) I have 5 devices currently running tasmota, 2 of them are WEMOS configured as Magichome devices to drive LED strips :-)

                          I've got a POW device thats now telling me when the dryer is finished, turns on the balcony lights and others that give me temp readings. When the temp on the balcony goes over 36C, I close the lounge motorised blinds when no one is home :-) All via mcsMQTT :-)

                          Pete
                          HS 2.2.0.11

                          Comment

                          Working...
                          X