[OBSOLETE] Smart Dehumidifier Control

Ok, so I think this will work but I would like to have you try it to be sure since I don’t have that Zooz sensor. The issue is simply that some (maybe most) sensors report %RH in whole (integer) values by rounding the value. In the case of the Zooz, it doesn’t do the rounding for you and just reports 100ths of %. I seriously doubt the sensor is < 1% accurate but anyhow it’s a valid way of reporting so we should catch that.

I verified these tweaks seem to work just fine with the whole % RH values and it should do the rounding for you if the % RH is reported as 10ths or 100ths (or well anything less than 1 % RH).

Before I release it, please give it a shot and let me know what errors or success you have please.

Edit the SmartApp and make the following changes to the humidityHandler() function :

From this:

def humidityHandler(evt) {
log.debug “humidity changed to: ${evt.value}%”
def currentHumidity = Integer.parseInt(evt.value.replace("%", “”))
state[frequencyLastRH(evt)] = currentHumidity

To This:

def humidityHandler(evt) {
def rawHumidity = Math.round(Double.parseDouble(evt.value.replace("%", “”)))
log.debug “humidity changed to: ${evt.value}% (${rawHumidity}%)”
def currentHumidity = rawHumidity.toInteger();
state[frequencyLastRH(evt)] = currentHumidity

And then do a Save and Publish, For Me to make it take effect Afterwards the app should start to use this code for the next execution. If you have any questions, let me know.

Thanks and let me know as soon as you have some results…

Thanks, I’m getting the following error while trying to update the smart app:

Ahh, the infamous smart quotes cut and past thing. In the line above, delete the second set of double quotes and redo them in the editor. It should be fixed.

Mail](https://go.microsoft.com/fwlink/?LinkId=550986) for Windows 10

Actually, I see the same thing on both the first two lines so just delete the quote character and redo it on both to be sure.

Mail](https://go.microsoft.com/fwlink/?LinkId=550986) for Windows 10

Great, many thanks, that fixed it and the smart app is working now!

v1.7 is up on GitHub.

The change is just to ensure that if %RH is reported as a fractional percent it is rounded to the nearest whole %RH for those sensors that don’t automatically do this. Given that most devices think about %RH in terms of 5% increments and that indoor humidity can change rapidly, working at a 1% precision level should be fine.

Thanks to @esalomo for finding this bug!

I get the “updating” notice. I am using a Xiaomi temperature/humidity sensor.

This is what the log for the sensor shows.

5:28:05 PM: debug Bedroom: Parse returned [name:humidity, value:54, unit:%]
5:28:05 PM: debug Bedroom: Parsing description: humidity: 54.14%
5:28:05 PM: debug Bedroom: Parsing description: humidity: 54.14%
5:28:05 PM: debug Bedroom: Parse returned [name:temperature, value:18.1, unit:C, descriptionText:Bedroom temperature is 18.1°C, translatable:true]
5:28:05 PM: debug Bedroom: Parsing description: temperature: 18.09
5:28:05 PM: debug Bedroom: Parsing description: temperature: 18.09

Can you provide the logs from the app itself? It might be similar to the previous issue but it would be good to see what the app is seeing and any errors it throws.

Hopefully these are the logs you refer to.


Well, not exactly. The one at the top is close (I would suggest clicking “all” in the top line instead of “from smartapp” and that will show you more. But the best thing to do is under Live Logging and filter by clicking on the app name as it appears (if it doesn’t, you can force it to appear by saving the settings in the app which will write a couple of lines to the log). Feel free to send the “all” log and the Live Logging filtered output. DM me if you like.

Good morning. I am having an issue where the humidity reading from my sensor is not reaching the smart app. The app continually shows “updating” for both the equipment status and the humidity reading. When I look at the “recently” tab for the sensor, it appears to be transmitting the humidity, along with the temperature and the pressure…

I am using version 1.7 of the app with a Xiaomi sensor.

Any ideas what may be causing the issue?

It could be a simple formatting of the data or similar that comes into the app. There was another user that seemed like he had the same issue (the previous posts to your message) but he never came back to me to debug it.

Basically we want to see what the app is thinking and any runtime errors and so on. You have to do this from the web “Graph API” interface. There are two types of logs: historical and live. If you’re looking at the historical logs then you’ll want to click on “all” at the top as I was noting in the post above. This will show you what the app has been doing but is probably not much given your description so what is even better is the Live Logging tab which shows you all the messages and errors. After clicking on Live Logging, you then will start to see events from various devices / apps and then you can click on the name of the device / app to filter its messages only. Since the app is not all that chatty, if you’re not seeing any messages immediately (i.e. the app name does not appear at the top for filtering) you can save the settings in the app instance and it will immediately populate a few messages,

If you have any questions about getting the logs let me know. Otherwise, feel free to DM me with the logs and I’ll take a look. I think it should be a simple fix unless the sensor is doing something really odd or ST for some reason isn’t propagating the messages meaning a DTH issue - but we’ll see.

Thank you for such a quick response! Below is the log from the sensor:

ThLogsClear
e2b2ecd1-9492-4c52-9635-26729945472c 4:04:12 PM: debug Basement Temp/Humidity Sensor: Parse returned [name:battery, value:91, unit:%, isStateChange:true, descriptionText:Basement Temp/Humidity Sensor Battery at 91% (2.955 Volts)]
e2b2ecd1-9492-4c52-9635-26729945472c 4:04:12 PM: debug SmartShield(text: null, manufacturerId: 0x0000, direction: 0x01, data: [0x01, 0xff, 0x42, 0x25, 0x01, 0x21, 0x8b, 0x0b, 0x04, 0x21, 0xa8, 0x43, 0x05, 0x21, 0x0a, 0x00, 0x06, 0x24, 0x01, 0x00, 0x00, 0x00, 0x00, 0x64, 0x29, 0x42, 0x07, 0x65, 0x21, 0xcf, 0x16, 0x66, 0x2b, 0x25, 0x80, 0x01, 0x00, 0x0a, 0x21, 0xf6, 0x30], number: null, isManufacturerSpecific: false, messageType: 0x00, senderShortId: 0x7c41, isClusterSpecific: false, sourceEndpoint: 0x01, profileId: 0x0104, command: 0x0a, clusterId: 0x0000, destinationEndpoint: 0x01, options: 0x0000)
e2b2ecd1-9492-4c52-9635-26729945472c 4:04:12 PM: debug Basement Temp/Humidity Sensor: Parsing description: catchall: 0104 0000 01 01 0000 00 7C41 00 00 0000 0A 01 01FF422501218B0B0421A84305210A0006240100000000642942076521CF16662B258001000A21F630

This is the log for the Dehumidifier switch:

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:19:53 PM: debug Parse returned [name:switch, value:on, isStateChange:true, displayed:true, linkText:Dehumidifier - Condo, descriptionText:Dehumidifier - Condo switch is on]

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:19:53 PM: debug [name:switch, value:on, type:switch]

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:19:53 PM: debug Parse: null

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:19:53 PM: debug Parsing ‘on/off: 1’

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:19:53 PM: debug Parse returned [name:switch, value:on, isStateChange:true, displayed:true, linkText:Dehumidifier - Condo, descriptionText:Dehumidifier - Condo switch is on]

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:19:53 PM: debug [name:switch, value:on, type:switch]

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:19:53 PM: debug Parse: null

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:19:53 PM: debug Parsing ‘on/off: 1’

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:17:28 PM: debug off()

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:17:28 PM: debug off()

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:15:55 PM: debug off()

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:15:55 PM: debug off()

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:15:16 PM: debug Parse returned [name:switch, value:on, isStateChange:false, displayed:false, linkText:Dehumidifier, descriptionText:Dehumidifier switch is on]

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:15:16 PM: debug [name:switch, value:on, type:switch]

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:15:16 PM: debug Parse: null

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:15:16 PM: debug Parsing ‘on/off: 1’

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:15:16 PM: debug Parse returned [name:switch, value:on, isStateChange:false, displayed:false, linkText:Dehumidifier, descriptionText:Dehumidifier switch is on]

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:15:16 PM: debug [name:switch, value:on, type:switch]

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:15:16 PM: debug Parse: null

2ea3718b-bb29-4e81-ae85-7f95dcdcb237 4:15:16 PM: debug Parsing ‘on/off: 1’

Thanks for the device logs. Just to be clear, we also need the app logs from the Live Logging tab. Let me know if this doesn’t make sense.

I hope that I chose the correct log:

fd3b06eb-5818-46e0-b4e7-446be01a00c2 7:18:43 PM: debug Updated with settings: [dehumidifier:Dehumidifier - Condo, humiditySensor:Basement Temp/Humidity Sensor, humiditySetpoint:68, humidityOvershoot:3, minCycleTime:60, openTime:5, maxRuntime:12, phone:6038676931]

fd3b06eb-5818-46e0-b4e7-446be01a00c2 7:18:43 PM: debug Updated with settings: [dehumidifier:Dehumidifier - Condo, humiditySensor:Basement Temp/Humidity Sensor, humiditySetpoint:68, humidityOvershoot:3, minCycleTime:60, openTime:5, maxRuntime:12, phone:6038676931]

fd3b06eb-5818-46e0-b4e7-446be01a00c2 7:18:41 PM: debug humidity (60%) is below 68% +/-3%, dehumidifier off

fd3b06eb-5818-46e0-b4e7-446be01a00c2 7:18:41 PM: debug humidity changed to: 60% (60%)

fd3b06eb-5818-46e0-b4e7-446be01a00c2 7:18:41 PM: debug humidity changed to: 60% (60%)

Now I am quite confused. The app shows the status as off but the device details shows that it is running. When I turn the device off in the dashboard, it turns itself back on even though the humidity sensor indicates that it should be off.

It looks like the app is having no issues getting the humidity reading from the sensor you have and the device should be off because 60% is less than 68% +/- 3%. If you set the setpoint to 50% then it should kick on.

Ok, so something is up. In the app settings it tells you the last status of the app (%RH and switch). It’s a static value that only updates when you open the settings tab.

What device do you use as the switch called “Dehumidifier - Condo”?

If the device is still on then I wonder if something is wrong with the switch device or if there could be something else that is toggling it like another app? The other historical log will tell us exactly what the app is doing. For reference that log is at:
My Locations -> smartapps -> Other -> “Name of App” -> List Events -> ALL

You should see when the app is issuing a command such as this:


If you’re not seeing corresponding on commands then it isn’t coming from this app. If you want to see which apps could be controlling your device you can see this in the Device settings:
My Devices -> “Name of Device” -> “In Use By” list

Let me know what you find, I’m sure we can get to the bottom of it.

Interestingly, I have the exact same arrangement at home. Same devices and settings. I MAY have found the issue to be with the device handler for the switch. The switch seems to have been reporting the correct status however the command to either turn off or on were not having no any effect. So when the app told the switch to turn off, the switch stayed on. When the switch was next polled the status correctly showed it to be on.

I changed the DH to one for a generic Zigbee switch. So far so good. The humidity readings are below the set point and the switch has remained off. I will see if it turns on properly when the set point is reached.

Jim Covart