fablabbcn / smartcitizen-api

The Smart Citizen Engine
https://developer.smartcitizen.me
GNU Affero General Public License v3.0
10 stars 4 forks source link

Non-existing sensors in `device` #326

Open oscgonfer opened 4 months ago

oscgonfer commented 4 months ago

I have seen a couple of times that a device has some "unreal" sensors in it.

image

I don't know where this comes from, but my gut tells me that this comes from some sort of malformed JSON .... (big if?)

oscgonfer commented 4 months ago

This is the list of sensors that we have on that device (https://smartcitizen.me/kits/17512):

[Sensor(id=113, name='AMS CCS811 - TVOC', description='Total Volatile Organic Compounds Digital Indoor Sensor', unit='ppb'),
 Sensor(id=112, name='AMS CCS811 - eCO2', description='Equivalent Carbon Dioxide Digital Indoor Sensor', unit='ppm'),
 Sensor(id=14, name='BH1730FVC - Light', description='Digital Ambient Light Sensor', unit='lux'),
 Sensor(id=10, name='Battery SCK', description='Custom Circuit', unit='%'),
 Sensor(id=53, name='ICS43432 - Noise', description='I2S Digital Mems Microphone with custom Audio Processing Algorithm', unit='dBA'),
 Sensor(id=219, name='NXP MPL3115A2 - Altitude', description='Altitude from digital barometric pressure sensor', unit='m'),
 Sensor(id=58, name='NXP MPL3115A2 - Barometric Pressure', description='Digital Barometric Pressure Sensor', unit='kPa'),
 Sensor(id=6, name='PVD-P8001', description='LDR Analog Light Sensor', unit='%'),
 Sensor(id=89, name='Plantower PMS5003 - PM1.0', description='Particle Matter PM 1', unit='ug/m3'),
 Sensor(id=88, name='Plantower PMS5003 - PM10', description='Particle Matter PM 10', unit='ug/m3'),
 Sensor(id=87, name='Plantower PMS5003 - PM2.5', description='Particle Matter PM 2.5', unit='ug/m3'),
 Sensor(id=165, name='Plantower PMS5003 - PN0.3', description='Particle Matter PN0.3', unit='#/0.1l'),
 Sensor(id=166, name='Plantower PMS5003 - PN0.5', description='Particle Matter PN0.5', unit='#/0.1l'),
 Sensor(id=167, name='Plantower PMS5003 - PN1.0', description='Particle Matter PN1.0', unit='#/0.1l'),
 Sensor(id=170, name='Plantower PMS5003 - PN10.0', description='Particle Matter PN10.0', unit='#/0.1l'),
 Sensor(id=168, name='Plantower PMS5003 - PN2.5', description='Particle Matter PN2.5', unit='#/0.1l'),
 Sensor(id=169, name='Plantower PMS5003 - PN5.0', description='Particle Matter PN5.0', unit='#/0.1l'),
 Sensor(id=158, name='SCD30 - CO2', description='Carbon Dioxide', unit='ppm'),
 Sensor(id=161, name='SCD30 - Humidity', description='Sensirion SCD30 Humidity', unit='%'),
 Sensor(id=160, name='SCD30 - Temperature', description='Sensirion SCD30 Temperature', unit='ºC'),
 Sensor(id=221, name='SD Card', description='SD Card Presence', unit=None),
 Sensor(id=56, name='Sensirion SHT31 - Humidity', description='Humidity', unit='%'),
 Sensor(id=55, name='Sensirion SHT31 - Temperature', description='Temperature', unit='ºC'),
 Sensor(id=220, name='Wi-Fi Antenna - RSSI', description='RSSI from Wi-Fi antenna', unit='dBm')]

Where this item is the conflicting one:

 Sensor(id=6, name='PVD-P8001', description='LDR Analog Light Sensor', unit='%'),

Not sure if we can even find it through the logs though...

oscgonfer commented 3 months ago

As mentioned, @timcowlishaw will work on improving the parsing and validation of the pseudoJSON from readings/raw in: app/lib/mqtt_messages_handler.rb

timcowlishaw commented 3 months ago

i think the way to do this would be to use Treetop (https://cjheath.github.io/treetop/) to write an actual parser for the pseudojson format. Leaving the link here so i don't forget!

oscgonfer commented 3 weeks ago

Related: https://github.com/fablabbcn/smartcitizen-api/issues/288