Push DNMS data to sensor.community

I want to push noise sensor data to sensor.community.
As it is an isolated spot, I use NBIoT, not WiFi.
I have tested the correct format for pushing single sensor date using a Pyhon script.
This works for fine dust data and temperature data, but not for noise data.
Do I need to use different variable names (tried: DMNS_noise_LA_max, noise_LA_max) ?
script output:
{‘P2’: ‘20.0’, ‘P1’: ‘30.0’}
<Response [201]>
{‘temperature’: ‘27.56’, ‘pressure’: ‘1024.00’, ‘humidity’: ‘55.50’}
<Response [201]>
{‘noise_Leq’: ‘44.00’, ‘noise_LA_min’: ‘33.00’, ‘noise_LA_max’: ‘55.00’}
<Response [400]>

script:
def read_values():
values = {}
cpu_temp = 33.3 #get_cpu_temperature()
raw_temp = 30.0 #bme280.get_temperature()
humid = 55.5
pressure = 1024

comp_temp = raw_temp - ((cpu_temp - raw_temp) / comp_factor)
values["temperature"] = "{:.2f}".format(comp_temp)
values["pressure"] = "{:.2f}".format(pressure)
values["humidity"] = "{:.2f}".format(humid)
values["P2"] = str(20.0)
values["P1"] = str(30.0)
values["noise_Leq"] = "{:.2f}".format(44.0)     
values["noise_LA_min"] ="{:.2f}".format(33.0)
values["noise_LA_max"] = "{:.2f}".format(55.0)
    
return values

def send_to_luftdaten(values, id):
pm_values = dict(i for i in values.items() if i[0].startswith(“P”))
noise_values = dict(i for i in values.items() if i[0].startswith(“n”))
temp_values = dict(i for i in values.items() if (not i[0].startswith(“P”)and not i[0].startswith(“n”)))

resp_1 = requests.post("https://api.luftdaten.info/v1/push-sensor-data/",
         json={
             "software_version": "enviro-plus 0.0.1",
             "sensordatavalues": [{"value_type": key, "value": val} for
                                  key, val in pm_values.items()]
         },
         headers={
             "X-PIN":    "1",
             "X-Sensor": id,
             "Content-Type": "application/json",
             "cache-control": "no-cache"
         }
)

resp_2 = requests.post("https://api.luftdaten.info/v1/push-sensor-data/",
         json={
             "software_version": "enviro-plus 0.0.1",
             "sensordatavalues": [{"value_type": key, "value": val} for
                                  key, val in temp_values.items()]
         },
         headers={
             "X-PIN":    "11",
             "X-Sensor": id,
             "Content-Type": "application/json",
             "cache-control": "no-cache"
         }
)

resp_3 = requests.post("https://api.luftdaten.info/v1/push-sensor-data/",
         json={
             "software_version": "enviro-plus 0.0.1",
             "sensordatavalues": [{"value_type": key, "value": val} for
                                  key, val in noise_values.items()]
         },
         headers={
             "X-PIN":    "15",
             "X-Sensor": id,
             "Content-Type": "application/json",
             "cache-control": "no-cache"
         }
)
print (pm_values)
print (resp_1)
print (temp_values)
print (resp_2)
print(noise_values)
print (resp_3)
if resp_1.ok and resp_2.ok:# and resp_3.ok:
    return True
else:
    return False

resp = send_to_luftdaten(values, id) #debug

Should be:
DNMS_noise_LAeq
DNMS_noise_LA_min
DNMS_noise_LA_max
for Madavi API

noise_LAeq
noise_LA_min
noise_LA_max
for SC API

Thank you for your quick answer. I have changed the script, but same result.
I use TTN profile. Could that be the problem ?

{‘P2’: ‘20.0’, ‘P1’: ‘30.0’}
<Response [201]>
{‘temperature’: ‘27.56’, ‘pressure’: ‘1024.00’, ‘humidity’: ‘55.50’}
<Response [201]>
{‘DNMS_noise_LAeq’: ‘44.00’, ‘DNMS_noise_LA_min’: ‘33.00’, ‘DNMS_noise_LA_max’: ‘55.00’}
<Response [400]>

Sibe Jan Koster

For the SC API
Remove « DNMS_ »

Thank you
I had a spelling error in the SC LAeq variable
It works now

Sibe Jan Koster

1 Like