sensebox / ttn-osem-integration

integration for thethingsnetwork.org to opensensemap.org
MIT License
6 stars 3 forks source link

Mapping data from TTN to OpenSenseMap #52

Closed proffalken closed 3 months ago

proffalken commented 3 months ago

Hello,

I'm using an [esp32-paxcounter]() to send data to OpenSenseMap from an SDS011 air quality monitor.

The decoded_payload field in the TTN response looks like this:

      "decoded_payload" : {
         "PM10" : 0,
         "PM25" : 0,
         "ble" : 9,
         "bytes" : [
            3,
            0,
            9,
            0,
            0,
            0,
            0,
            0
         ],
         "pax" : 12,
         "port" : 1,
         "wifi" : 3
      },

I have set the decoder to LoRa Serialization as stated in the documentation, but I have no idea how these fields then map to the appropriate decoder object.

I would expect the following decoder to put the data in the correct locations, but it fails to do so:

[{"decoder": "uint16", "sensor_type": "pm10"},{"decoder": "uint16", "sensor_type": "pm25"},{"decoder": "uint16", "sensor_type": "ble_devices"},{},{"decoder": "uint16", "sensor_type": "people"},{"decoder": "uint16", "sensor_type": "port"},{"decoder": "uint16", "sensor_type": "wifi_devices"}]

Note that for the bytes array I've just included a null object {}

mpfeil commented 3 months ago

Hi @proffalken,

thanks for opening up that question. I am on parental leave at the moment. But maybe @felixerdy could help you with it. Or if I find some free time I will give it a try.

proffalken commented 3 months ago

@mpfeil - thanks, I managed to get it working via the email support channels.

Instead of sensor_type I needed to do sensor_id, and I needed to set the serialization to loraserialization rather than JSON.

I'm not sure why sensor_type didn't work, and it's a bit of a shame because I've got quite a few of these sensors to setup and was hoping to template them out using the API, but I'll just make multiple calls to create and select the sensor ID's and then add them to the decoder instead.

mpfeil commented 3 months ago

Hi @proffalken

thanks for your reply and good to hear that you have managed it.

After my parental leave I am going to work on the TTN integration because it is pretty rudimentary.

We planned providing a console with feedback. But I will keep your suggestion in mind.

proffalken commented 3 months ago

Amazing!

I only know python, but if there's anyway I can help with testing etc. then please do let me know - our Hackspace is building a number of sensors based on the ESP32-PaxCounter hardware with SDS011 particle sensors and BME680 environment sensors, and we're hoping to use TTN + OpenSenseMap to visualise all the data!

Also, congratulations on the new arrival - I remember those days well, hope you and your partner are getting some sleep! :D