Announcement

Collapse
No announcement yet.

Purple Air

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

    Purple Air

    Hello to all
    I have been using purpleair.exe by dzee for the last 3-4 years. Working great up until 5/26/2022, when it stopped giving me data.
    Looking at things, it looks like Purple Air changed things and now the exe give a 500 error.
    I don't know if this has happened for others, but I'd like to get back up and running somehow.
    I don't know if I just need to change a URL or what.
    Any help would be appreciated
    Thanks
    Bruce (Dbvanb) - I am running on linux with mono 6

    #2
    Yes. PurpleAir deprecated the json and data.json endpoints on 5/26/2022. You now have to request an API key in order to access sensor data. The old endpoints re-direct to a non-existent service, thus the 500 error.

    https://community.purpleair.com/t/di...-json-urls/713

    I just got around getting my API key yesterday and I'm working on a Node-RED polling implementation.

    I'll post the updated version here: https://forums.homeseer.com/forum/ho...59#post1553559

    Comment


      #3
      I had done a Purpleair integration with mcsMQTT in the past. While the specific URL data has changed with the new API key, the approach remains the same with a setup on the URL tab of mcsMQTT and then the decoded JSON available on the Association tab for mapping desired items into HS Device Features.

      Comment


        #4
        I used mcsMQTT for a while before I decided to start playing with Node-RED. One additional thing that's changed is that they ask you to request the data for multiple sensors in a single request. At least for me this definitely complicates the parsing of the JSON data.

        I'm using the 'https://api.purpleair.com/v1/sensors' endpoint with the show_only parameter with a list of sensor_index values to return. The returned JSON data contains an array of arrays with the sensor data.

        Comment


          #5
          Makes no difference to mcsMQTT with an array of arrays. This actually was the primary reason I transitions to Newtonsoft library rather than the native code parsing. The cloud providers have much more complex JSON structures than the typical microcontroller that was the genesis of mcsMQTT. The time it can become a problem is if PurpleAir changes the order of the sensors in the array. The default parsing uses the array index. The elevate key capability of mcsMQTT often is able to deal with it and keep identication in sync.

          I have not gone back to get an API key as I do not use the PurpleAir data. I just observed that the change on their end was minor with respect to being able to get the desired data.

          When I first did this, I had setup a .pub file that lists the individual URL requests. This same approach can still be used and avoid nested arrays.

          Node-Red is a fine way to handle data and build logic trees. As with many things the casual HS users is intimidated by the learning curve, even though in the end it opens capability that may not otherwise be available.

          Comment


            #6
            Thanks for the information, Kenm and Michael.
            now I have an idea what to do to get going again.
            Some work to do.
            Bruce

            Comment


              #7
              Michael McSharry .Pub lists are something they are asking us not to use anymore. Instead of making multiple single sensor requests, they are asking us to make a single request for data from multiple sensors. They return 2 arrays. The first array is called "fields" and each element is the name of the data values being returned. Think of this as the column header in a spreadsheet. The second array is 2-dimensional. Think of this as the rows of data being returned with the order defined by the fields array. They DO NOT guarantee the data will be in the same order every time, only that it will match the fields array. Makes positional parsing very fragile.

              Comment

              Working...
              X