tsathishkumar / MySController-rs

Controller for MySensors, exposes WoT APIs for the sensors. It supports OTA firmware updates, and also acts as proxy for all requests.
GNU Affero General Public License v3.0
20 stars 9 forks source link

Support for AirQuality Sensor #20

Closed tsathishkumar closed 5 years ago

tsathishkumar commented 5 years ago

@flatsiedatsie I have pushed the support for AirQuality sensor. Could you take a pull and test again and update if it works.

flatsiedatsie commented 5 years ago

I believe there are multiple types of air quality sensors.

CO2 For CO2 the level ranges between 0 (actually, 400 is the minimum you will ever get) and 5000. Some versions range between 0 and 2000.

http://www.aliexpress.com/item/1PCS-module-MH-Z19-infrared-co2-sensor-for-co2-monitor-Free-shipping/32371956420.html

DUST Fine dust sensors measure dust in ug/m3 (microgram per meter squared), and range between 0.0 and 1000. They usually measure multiple 'buckets', such as particles with diameters of 1nm and 2.5nm and 10nm.

https://forum.mysensors.org/topic/6404/next-generation-dust-sensor-for-mysensors

CO Carbon monoxide is measure in particles per million (ppm), ranging from 0 till 1500.

Often sensors will also output a text that translates the level into a human readable value. For example "safe" or "good". My devices do this for all air quality sensor types.

Here are some acceptable levels for carbon monoxide: http://www.carbonmonoxidekills.com/are-you-at-risk/carbon-monoxide-levels/

Other gasses

Nitrogen dioxide NO2 0.05 – 10ppm Ethanol C2H5OH 10 – 500ppm Hydrogen H2 1 – 1000ppm Ammonia NH3 1 – 500ppm Methane CH4 >1000ppm Propane C3H8 >1000ppm Iso-butane C4H10 >1000ppm

volatile organic compounds are also popular to measure. These are, for example, released from paint and plastic.

flatsiedatsie commented 5 years ago

I tested it. I think something is wrong.

What pops up is (another) humidity sensor. But in the Mozilla Gateway interface it only has an on-off switch bubble attached to it, and not a sensor value bubble.

Perhaps the issue is that this device was added earlier, but only now it's delivering data?

Here's the complete 8888 json:

[
  {
    "@context": "https://iot.mozilla.org/schemas",
    "@type": [
      "multiLevelSensor"
    ],
    "actions": {},
    "description": "Air Quality sensor",
    "events": {},
    "href": "/0",
    "links": [
      {
        "href": "/0/properties",
        "rel": "properties"
      },
      {
        "href": "/0/actions",
        "rel": "actions"
      },
      {
        "href": "/0/events",
        "rel": "events"
      },
      {
        "href": "ws://192.168.2.110:8888/0",
        "rel": "alternate"
      }
    ],
    "name": "CO2 sensor - Air Quality sensor",
    "properties": {
      "level": {
        "description": "Level output of the sensor",
        "href": "/0/properties/level",
        "type": "number",
        "unit": ""
      },
      "unit": {
        "description": "Unit of the sensor output",
        "href": "/0/properties/unit",
        "type": "string",
        "unit": ""
      }
    }
  },
  {
    "@context": "https://iot.mozilla.org/schemas",
    "@type": [
      "onOffSwitch"
    ],
    "actions": {},
    "description": "Lock device",
    "events": {},
    "href": "/1",
    "links": [
      {
        "href": "/1/properties",
        "rel": "properties"
      },
      {
        "href": "/1/actions",
        "rel": "actions"
      },
      {
        "href": "/1/events",
        "rel": "events"
      },
      {
        "href": "ws://192.168.2.110:8888/1",
        "rel": "alternate"
      }
    ],
    "name": "SMS & password relays - Lock device",
    "properties": {
      "on": {
        "description": "Whether lock is on or not",
        "href": "/1/properties/on",
        "type": "boolean",
        "unit": ""
      }
    }
  },
  {
    "@context": "https://iot.mozilla.org/schemas",
    "@type": [
      "onOffSwitch"
    ],
    "actions": {},
    "description": "Lock device",
    "events": {},
    "href": "/2",
    "links": [
      {
        "href": "/2/properties",
        "rel": "properties"
      },
      {
        "href": "/2/actions",
        "rel": "actions"
      },
      {
        "href": "/2/events",
        "rel": "events"
      },
      {
        "href": "ws://192.168.2.110:8888/2",
        "rel": "alternate"
      }
    ],
    "name": "SMS & password relays - Lock device",
    "properties": {
      "on": {
        "description": "Whether lock is on or not",
        "href": "/2/properties/on",
        "type": "boolean",
        "unit": ""
      }
    }
  },
  {
    "@context": "https://iot.mozilla.org/schemas",
    "@type": [
      "onOffSwitch"
    ],
    "actions": {},
    "description": "Lock device",
    "events": {},
    "href": "/3",
    "links": [
      {
        "href": "/3/properties",
        "rel": "properties"
      },
      {
        "href": "/3/actions",
        "rel": "actions"
      },
      {
        "href": "/3/events",
        "rel": "events"
      },
      {
        "href": "ws://192.168.2.110:8888/3",
        "rel": "alternate"
      }
    ],
    "name": "SMS & password relays - Lock device",
    "properties": {
      "on": {
        "description": "Whether lock is on or not",
        "href": "/3/properties/on",
        "type": "boolean",
        "unit": ""
      }
    }
  },
  {
    "@context": "https://iot.mozilla.org/schemas",
    "@type": [
      "multiLevelSensor"
    ],
    "actions": {},
    "description": "Temperature sensor",
    "events": {},
    "href": "/4",
    "links": [
      {
        "href": "/4/properties",
        "rel": "properties"
      },
      {
        "href": "/4/actions",
        "rel": "actions"
      },
      {
        "href": "/4/events",
        "rel": "events"
      },
      {
        "href": "ws://192.168.2.110:8888/4",
        "rel": "alternate"
      }
    ],
    "name": "Temperature and more sens - Temperature sensor",
    "properties": {
      "level": {
        "description": "Temperature",
        "href": "/4/properties/level",
        "type": "number",
        "unit": "celsius"
      },
      "on": {
        "description": "Whether the thing is on",
        "href": "/4/properties/on",
        "type": "boolean",
        "unit": ""
      }
    }
  },
  {
    "@context": "https://iot.mozilla.org/schemas",
    "@type": [
      "multiLevelSensor"
    ],
    "actions": {},
    "description": "Humidity sensor",
    "events": {},
    "href": "/5",
    "links": [
      {
        "href": "/5/properties",
        "rel": "properties"
      },
      {
        "href": "/5/actions",
        "rel": "actions"
      },
      {
        "href": "/5/events",
        "rel": "events"
      },
      {
        "href": "ws://192.168.2.110:8888/5",
        "rel": "alternate"
      }
    ],
    "name": "Temperature and more sens - Humidity sensor",
    "properties": {
      "level": {
        "description": "Humidity",
        "href": "/5/properties/level",
        "type": "number",
        "unit": ""
      }
    }
  }
]
tsathishkumar commented 5 years ago

Interesting, in the wot api it shows that the sensor is multi level. So ideally it should have values associated.

"@context": "https://iot.mozilla.org/schemas",
    "@type": [
      "multiLevelSensor"
    ],
    "actions": {},
    "description": "Air Quality sensor",
tsathishkumar commented 5 years ago

Is it still happening? Or can it be closed?

flatsiedatsie commented 5 years ago

I think this was part of the other issue where the things had 'shifted'.