Announcement

Collapse
No announcement yet.

Help with json and python 3

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

    Help with json and python 3

    I'm looking for a quick tip on how to post a json string to homeseer from a raspberry pi running python3.

    I thought that I would play around with a raspberry pi 3b+ and start off with installing python and setting up a DHT22 temperature/humidity sensor on it. This was fairly simple and I have succeeded in using a python script to read the sensor and print the values to the console. Next step is to update a newly created virtual device on my HS3 with the temperature from the raspberry pi. The simplest method would seem to be to excecute a json function, but after 2 hours of searching and testing, I cannot get python to run the json post such that it communicates properly with HS3.

    This simple json string run from a web browser will update my virtual device properly (with a test value of 12): http://192.168.254.211/JSON?request=...f=493&value=12

    It appears that the "requests.post" function in python 3 is the function that I should be using, but I cannot figure out how to build the json payload properly for it to communicate with HS3. Any help would be appreciated.

    #2
    Did you work this out?
    I'm keen to put a few DHT22's on a RPI I have too, and I'm not great with JSON or python....

    Comment


      #3
      Hi Area_49,

      I just noticed these posts. Did you ever get it figured out? I have done something similar with a raspberry pi, DHT22, and one wire temp sensors. I did not use json, but rather mqtt. I use a python script on the raspberry pi, which will send a mqtt message. The mqtt server happens to be on the same raspberry pi. I then use mcsMQTT plugin on my homeseer computer, which is a rock64 (a raspberry pi clone or similar SBC). The mcsMQTT plugin receives the mqtt message and creates a homeseer device and then will update it everytime it receives the mqtt message from the raspberry pi. Works very well. The mcsMQTT plugin does understand json as a mqtt message.
      It also will keep a history and graph the results over time, which I use often and display on wall tablets.

      Bruce

      Comment


        #4
        I use esp8266 modules for the DHT22 sensors.
        i have a arduino template.
        That template hasa humidity,temperature,wifistate,ssid,and motion sensor in one, that sends a big mqtt payload to homeseer
        That one will send the correct mqtt payload to homeseer received by mcsmqtt.

        i have many devices arround the house working great, no python needed.
        Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
        Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




        HS3Pro 4.0.8.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

        Comment


          #5


          This multi sensor is found on the github from BRUH automation,
          https://github.com/bruhautomation/ES...ON-Multisensor also video available

          i did create the dashboard and edited the variables, but take a look how he did the coding.
          Click image for larger version  Name:	node2.png Views:	0 Size:	535.5 KB ID:	1393333
          Attached Files
          Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
          Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




          HS3Pro 4.0.8.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

          Comment

          Working...
          X