Reading Air Quality measurements from Samsung Air Purifier

Hi! I have a Samsung AX90R7080WD Air Purifier which connects directly to my home WiFi. I can control it using the SmartThings app on my iPhone. In the app I can also see its air quality measurements. However I have several gadgets at my home that I collect measurements from. Temperature sensors, light sensors, door sensors, etc. I use NodeRed, MQTT, InfluxDB and Grafana to analyze historical data on nice charts from the different sensors.
I would like to have all the air quality measurements added to my charts, so I could analyze the air quality over time and correlate it to door movements and temperature readings.
However Iā€™m new to the SmartThings ecosystem and I donā€™t know how I could access my air purifier and read the measurements from it through an API or any other integration.
So here are my questions:

  • Is there a way to connect to my device on local network to read the measurements?
  • What kind of integration is needed with the SmartThings ecosystem in order to read those data.
  • Is there a build in functionality that stores historical data or do I have to set up a database for those?
    Thank you!
1 Like

Not really, only if you could do local provision of the OCF part, but I think that is impossible without the correct key.

You need to access the SmartThings API, and have a look how the values are published to the API. It is quite simple to find it out just look at the documentation. You can test it with PostMan or with the SmartThings CLI.

You can search for some legacy SmartApps which post data to InfluxDB, but once the Groovy IDE will be retired it will be gone as well.

Look at Samsung Automation Studio (@Automated_House is that the name of the Samsung Node-Red solution? Can you share a link?), that might be a good use, I am not sure. Otherwise there are some custom Node-Red packages for SmartThings as well just need to do some search.

1 Like

Thatā€™s the one. https://sasm.developer.samsung.com/

Thank you! I was able to connect to my device using the SmartThings REST API using PostMan. :slight_smile:

I was able to read the status of the device, getting all the current air quality measurements, fan mode, etc. Also I was able to turn it on and off using commands.

I think I will be able to add these API calls to my own NodeRed installation and periodically poll the device for the current readings so I can add those to my InfluxDB timeseries database and visualize them.

Also I might try to create a HomeBridge plugin for my device so I can turn it on and off from my Apple HomeKit integration. There was a previous HomeBridge plugin for SmartThings but it says that itā€™s not working anymore because of the SmartApps deprecation. tonesto7/homebridge-smartthings I wonder if it would be possible to create a new HomeBridge plugin using the SmartThings API instead. Anyone could just create a personal token, configure it in the HomeBridge plugin config and boom, you could see all your SmartThings devices in your Apple Home.

I have found the documentation for some of the capabilities here:

But a more extensive list of the capabilities is here:

My device has the following capabilities that are relevant for me:
dustSensor (PM10, PM2.5)
veryFineDustSensor (PM1.0)
switch (on/off)
airConditionerFanMode
samsungce.lamp

Originally I was a bit confused of all the different integration options that are on the website: smart apps, automations, webhooks, etc. Iā€™m still not sure what those are for, but the simple REST API is perfect for me. Thank you for your help!

1 Like

I was able to do the integration in my own NodeRed instance. There was one trick though. I had to call the refresh command every time before reading the device status or else I got stale data.

The refresh looks like this:
POST https://api.smartthings.com/v1/devices/{deviceId}/commands
{"commands":[{"component": "main","capability": "refresh","command": "refresh","arguments": []}]}

This is how the result looks like:

3 Likes

Here is a screenshot about a 3 hour period of my measurements:

3 Likes

Actually you should really use Webhook with callback, then you could subscribe to changes from the device and get the data pushed to your Node-Red setup. But the data being stale in the API makes me think that it wouldnā€™t really work better than how you do it.

The device should push the values to ST cloud automatically and the API should reflect that.
But being a cloud based API with API call limits, I guess it is not happening like that.

1 Like

I have found this capability in the device status that makes me think that realtime updates are disabled and that is why I have to explicitly call the refresh command to get a fresh measurement:

            "custom.deviceReportStateConfiguration": {
                "reportStateRealtimePeriod": {
                    "value": "disabled",
                    "timestamp": "2021-06-30T10:05:21.719Z"
                },
                "reportStateRealtime": {
                    "value": {
                        "state": "disabled"
                    },
                    "timestamp": "2021-07-07T15:53:08.615Z"
                },
                "reportStatePeriod": {
                    "value": "disabled",
                    "timestamp": "2021-06-30T10:05:21.719Z"
                }
            },

Iā€™m not sure if that could be enabled somehow.

Hey, @Henko

First Iā€™d like to congratulate you on the results. Iā€™ve really enjoyed looking at these charts :nerd_face:.

Now, to get more into the context of the custom.deviceReportStateConfiguration capability, I recommend you to check out its definition at {{API_URL}}/capabilities/custom.deviceReportStateConfiguration/1.

And if you enjoy navigating yourself through the terminal, I recommend you to set up the SmartThings CLI and track the capability with this command:

smartthings capabilities custom.deviceReportStateConfiguration --json

Thanks @erickv I will try that out!

Fun: Here is the chart for the whole day. I have changed the scale to log10 to better track smaller changes as well. The red at the bottom is the airQuality score which is from 1-5, 1 being super clean and 5 being unhealthy. You can clearly see the two toast cheese sandwiches that I made in the kitchen this morning. :smiley: There was no smoke, but you could definitely smell the delicious scent of them. :smiley: Clearly my air purifier wasnā€™t so happy about them. :smiley:

2 Likes