My SmartApp works, but some of the data is stale?

Hi, I’m not entirely sure which forum this comes under, so starting out in here…

I have a working SmartApp (my first one) - which polls 4 x Samsung AirCon units, retrieves the Temperature and Humidity values and then posts them (via HTTP) to my Cacti server, which graphs them.

It works - but - the humidity values (only) are stale. Temperature updates in realtime, but humidity only changes when i ‘poll’ it using the SmartThings application on my phone. Once i poll it on there, the value which is given to my SmartApp updates itself, and then remains stale until the next time i manually poll that A/C unit.

Relevant code extracts

Unit Selection:

    section("Select an Air Conditioning Unit") {
    input "temp", "capability.temperatureMeasurement", title: "Temperature", required: true
    input "humidity", "capability.relativeHumidityMeasurement", title: "Humidity", required: true
    }

Temperature Reference:
"value": temp.currentTemperature

Humidity Reference:
"value": humidity.currentHumidity

So, to clarify, the application works, but the data for humidity (only) becomes stale unless i click the little ‘Refresh’ button on the Air Conditioning unit item within the SmartThings device page on my phone.

TLDR; How do i issue a ‘refresh’ command to poll the latest humidity like the application does?

Thanks in advance!

Are you using a DTH from smartthings or you wrote yours?
Since you are saying the device refresh updates the humidity, to me it means the DTH is the problem.
Your smartapp should update upon the same events as the DTH. If the DTH doesn’t update first, nothing is going to happen at the smartapp level.

If in the DTH Refresh method, you don’t see the same codes as the polling method or whatever if used to update the DTH, then that could explain the behavior.

If the DTH doesn’t send the humidity event upon normal update but only as the refresh result, that could also cause this issue.

1 Like

Thanks for that, some additional details…

The device is a Samsung A/C unit and the handler is the default / factory one. The only code I’ve produced is the collection of the reading and posting it to my Cacti server in a single SmartApp.

As a test, I setup runEvery1Minute(updateCacti) to make it send the readings every minute, instead of only when they ‘change’. However, this still had the same results. The temperature was always working fine and updating immediately, but the humidity is stale until i push the ‘refresh’ button on this page:

As you can see, by default when you open it, the humidity is just “-” which says to me that it’s not being polled until i push the refresh. I have no idea why they would make this different to the temperature (which is always realtime when you view it).

So if this is the issue, how can i trigger this ‘refresh’ myself do you think?

ok so clearly this is not your smartapp issue.
Since this is used in the new smartthings app, I would reach out to ST support. They have to get the DTH fixed.

Till you see a humidity value displayed by the DTH, nothing will happen at your smartapp level. I believe your updateCacti is just looping on the units and get values of them then send that to your http server.
So as you have “-” for the humidity, getting the value of this measure can only return the same.

You can have a try to log in the IDE and check the logs of the DTH and specially check for errors it could display between updates and forced refresh

Sounds reasonable yes, interestingly if i just post the .relativeHumidityMeasurement every minute, it sends me the last reading, rather than ‘null’ or ‘-’ so clearly something is intentionally caching it somewhere.

I did a test and performed two functions while logging the events, but since i’m new to this platform i’ve little idea of what this means yet.

A normal “Turn unit on” (no RH reading shown yet, just “-”):

07:28:13: debug parsed mode: cool [[cool, dry, wind, auto, heat]]
07:28:13: debug parsed mode false false
07:28:13: debug parseMode : options[[Comode_Off, Sleep_0, OutdoorTemp_74, CoolCapa_25, WarmCapa_32, Spi_Off, Autoclean_Off, Light_Off, Volume_Mute, AirMonitoring_Off, AutocleanProgress_0, StopAutoClean_Idle, FilterTime_100, FilterAlarmTime_500, OptionCode_35882, ExtendOptionCode_5, RacInfo_None, UpdateAllow_NotAllowed]]
07:28:13: trace DA-AC-RAC-000001 /oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/mode/vs/0
07:28:13: debug In parse() message: {"correlationId":"cfa1bba9-6146-7fd9-d05c-46b0573d99ce","receiverDi":"dealer","enqueueTime":1566800893298,"path":"/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/mode/vs/0","data":{"payload":{"x.com.samsung.da.supportedModes":["Cool","Dry","Wind","Auto","Heat","HOMECARE_WIZARD_V2"],"x.com.samsung.da.options":["Comode_Off","Sleep_0","OutdoorTemp_74","CoolCapa_25","WarmCapa_32","Spi_Off","Autoclean_Off","Light_Off","Volume_Mute","AirMonitoring_Off","AutocleanProgress_0","StopAutoClean_Idle","FilterTime_100","FilterAlarmTime_500","OptionCode_35882","ExtendOptionCode_5","RacInfo_None","UpdateAllow_NotAllowed"],"if":["oic.if.baseline","oic.if.a"],"rt":["x.com.samsung.da.mode"],"x.com.samsung.da.modes":["Cool"]}},"senderDi":"c45c3932-fa2f-a642-2954-becd60a12a6b"}
07:28:13: trace DA-AC-RAC-000001 /oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/mode/0
07:28:13: debug In parse() message: {"correlationId":"fc57c566-81c4-d1cf-c6ed-ece6e42c5071","receiverDi":"dealer","enqueueTime":1566800893271,"path":"/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/mode/0","data":{"payload":{"supportedModes":["Cool","Dry","Wind","Auto","Heat","HOMECARE_WIZARD_V2"],"if":["oic.if.baseline","oic.if.a"],"modes":["Cool"],"rt":["oic.r.mode"]}},"senderDi":"c45c3932-fa2f-a642-2954-becd60a12a6b"}
07:28:13: debug set drlcLevel to -1 (NOT_SUPPORTED)
07:28:13: warn Initial get error, method:GET, status:200, path:/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/drlc/vs/0
07:28:13: trace DA-AC-RAC-000001 /oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/power/vs/0
07:28:12: debug In parse() message: {"correlationId":"8407e4c2-ba41-a4de-7eaa-445081f4d180","receiverDi":"dealer","enqueueTime":1566800892944,"path":"/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/power/vs/0","data":{"payload":{"if":["oic.if.baseline","oic.if.a"],"rt":["x.com.samsung.da.operation"],"x.com.samsung.da.power":"On"}},"senderDi":"c45c3932-fa2f-a642-2954-becd60a12a6b"}
07:28:13: trace DA-AC-RAC-000001 /oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/power/0
07:28:13: debug In parse() message: {"correlationId":"04675663-3cd7-097d-98fc-0b1c939bf2c9","receiverDi":"dealer","enqueueTime":1566800892933,"path":"/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/power/0","data":{"payload":{"if":["oic.if.baseline","oic.if.a"],"value":true,"rt":["oic.r.switch.binary"]}},"senderDi":"c45c3932-fa2f-a642-2954-becd60a12a6b"}

Next, I pushed the ‘refresh’ button in the app, and got my humidity update:

07:28:46: trace DA-AC-RAC-000001 /oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/humidity/vs/0
07:28:46: debug In parse() message: {"correlationId":"011156e3-dfd6-27b5-a282-a2d5a151759b","receiverDi":"dealer","enqueueTime":1566800926739,"path":"/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/humidity/vs/0","data":{"payload":{"x.com.samsung.da.humidity":"55","if":["oic.if.baseline","oic.if.a"],"rt":["x.com.samsung.da.humidity"]}},"senderDi":"c45c3932-fa2f-a642-2954-becd60a12a6b"}
07:28:46: trace DA-AC-RAC-000001 /oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/humidity/0
07:28:46: debug In parse() message: {"correlationId":"622a8968-9d74-244b-d4f1-0b4d2505b10f","receiverDi":"dealer","enqueueTime":1566800926750,"path":"/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/humidity/0","data":{"payload":{"humidity":55,"if":["oic.if.baseline","oic.if.a"],"rt":["oic.r.humidity"]}},"senderDi":"c45c3932-fa2f-a642-2954-becd60a12a6b"}
07:28:46: trace DA-AC-RAC-000001 /oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/mode/0
07:28:46: debug In parse() message: {"correlationId":"98499aa8-4b90-2b27-3f20-653d1c61d989","receiverDi":"dealer","enqueueTime":1566800926369,"path":"/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/mode/0","data":{"payload":{"supportedModes":["Cool","Dry","Wind","Auto","Heat","HOMECARE_WIZARD_V2"],"if":["oic.if.baseline","oic.if.a"],"modes":["Cool"],"rt":["oic.r.mode"]}},"senderDi":"c45c3932-fa2f-a642-2954-becd60a12a6b"}
07:28:46: debug parsed mode: cool [[cool, dry, wind, auto, heat]]
07:28:46: debug parsed mode false false
07:28:46: debug parseMode : options[[Comode_Off, Sleep_0, OutdoorTemp_74, CoolCapa_25, WarmCapa_32, Spi_Off, Autoclean_Off, Light_Off, Volume_Mute, AirMonitoring_On, AutocleanProgress_0, StopAutoClean_Idle, FilterTime_100, FilterAlarmTime_500, OptionCode_35882, ExtendOptionCode_5, RacInfo_None, UpdateAllow_NotAllowed]]
07:28:46: trace DA-AC-RAC-000001 /oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/mode/vs/0
07:28:46: debug In parse() message: {"correlationId":"1ec32ac6-be53-8acd-734a-c1a9780b2bed","receiverDi":"dealer","enqueueTime":1566800926363,"path":"/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/mode/vs/0","data":{"payload":{"x.com.samsung.da.supportedModes":["Cool","Dry","Wind","Auto","Heat","HOMECARE_WIZARD_V2"],"x.com.samsung.da.options":["Comode_Off","Sleep_0","OutdoorTemp_74","CoolCapa_25","WarmCapa_32","Spi_Off","Autoclean_Off","Light_Off","Volume_Mute","AirMonitoring_On","AutocleanProgress_0","StopAutoClean_Idle","FilterTime_100","FilterAlarmTime_500","OptionCode_35882","ExtendOptionCode_5","RacInfo_None","UpdateAllow_NotAllowed"],"if":["oic.if.baseline","oic.if.a"],"rt":["x.com.samsung.da.mode"],"x.com.samsung.da.modes":["Cool"]}},"senderDi":"c45c3932-fa2f-a642-2954-becd60a12a6b"}

(My SmartApp was disabled to avoid unnecessary logging).

The more i think about it, the more i reckon this is to reduce overhead (at scale) on the platform. Relative humidity is very dynamic and temperature (when measured only in whole number units) is not as changeable. So maybe Samsung decided that only temperature needs to update automatically.

Instructions to these seem unique to the humidity refresh button push…

/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/humidity/0
/oic/route/c45c3932-fa2f-a642-2954-becd60a12a6b/humidity/vs/0

I’ll pass the same info to support, but do you have any ideas how i can send the equivalent ‘update’ event myself? Or is this something that can only be ‘sent’ from a device handler?

Thanks again!