Is there a way to edit or add code to the Konnected temperature and humidity (DHT) driver to adjust + or - the humidity output from this driver?
I recommend you reach out to @nate over in the Konnected forums. He's very responsive to end-user questions.
I reached out to Nate, below is his response.
" Hi Dan,
I have mentioned it but he doesn't have time at the moment to look at it. There should be a line in the code for conversion that can easily be modified.
Andy Wulff
Konnected Customer Support Specialist
Any Konnected users out there that can take a look at offsetting the humidity output via the konnected Temperature & Humidity Sensor (DHT) Driver?
I am not a Konnected user, however I have taken a stab at adding Humidity and Temperature offsets to the Konnected temperature and humidity driver. I haven't tested it, but it is a pretty simple change (I copied code from my HubDuino drivers.) Give it a shot and let me know if it works!
old code removed avoid any user confusion.
See a few posts down for current working code.
EDIT: Working code can be found in this post Konnected temperature and humidity (DHT) driver Help - #15 by ogiewon
I placed the new code where I think it should go. The offsets show up on the device preferences page but the humidity output does not change.
Looks like you missed some of the changes. Simply go to my original code in the post above, select and "COPY" all of the code, then go into your hub's Drivers Code, open the Konnected Temp & Humidity driver, delete all of the code, then paste in the code you copied earlier, and click SAVE.
I replaced the driver code with your code in its entirety. The code pasted into hubitat with no errors but the offsets are not recognized.
The offsets will only be applied when the next temperature or humidity update is reported from the device. Maybe that’s what you’re experiencing?
If the device is set to poll every 3 minutes, and I have added a value in the offset, wouldn't it update to the adjusted value within 3 minutes?
I would think so, but I don’t know the inner workings of Konnected.
I waited 15 min or so and no update. When I removed the offset values the temp and humidity numbers updated.
So, what do you see in the Hubitat Hub’s LOGS when you have the offsets enabled? Perhaps there is an error message that might help us figure out what is wrong?
Yep, thanks for the logs. I am working on the fix.
Please give this version a try. Again, simply clear out the current contents of the Custom Driver code, and past all of the following code in, then click SAVE.
/**
* Konnected Temperature & Humidity Sensor (DHT)
*
* Copyright 2018 Konnected Inc (https://konnected.io)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*
* Modification History:
*
* 2022-01-06 Dan Ogorchock Added Tenmperature and Humidity optional offsets
*
*/
metadata {
definition (name: "Konnected Temperature & Humidity Sensor (DHT)", namespace: "konnected-io", author: "konnected.io", mnmn: "SmartThings", vid: "generic-humidity") {
capability "Temperature Measurement"
capability "Relative Humidity Measurement"
}
preferences {
input name: "pollInterval", type: "number", title: "Polling Interval (minutes)",
defaultValue: defaultPollInterval(),
description: "Frequency of sensor updates"
input "tempOffset", "number", title: "Temperature Offset", description: "Adjust temperature by this many degrees", range: "*..*", displayDuringSetup: false
input "humidityOffset", "number", title: "Humidity Offset in Percent", description: "Adjust humidity by this percentage", range: "*..*", displayDuringSetup: false
}
}
def updated() {
parent.updateSettingsOnDevice()
}
// Update state sent from parent app
def updateStates(states) {
def temperature = new BigDecimal(states.temp)
if (location.getTemperatureScale() == 'F') {
temperature = temperature * 9 / 5 + 32
}
if (tempOffset) {
def temperatureOffset = new BigDecimal(tempOffset)
temperature = temperature + temperatureOffset
}
sendEvent(name: "temperature", value: temperature.setScale(1, BigDecimal.ROUND_HALF_UP), unit: location.getTemperatureScale())
def humidity
if (states.humi) {
humidity = new BigDecimal(states.humi)
if (humidityOffset) {
def humiOffset = new BigDecimal(humidityOffset)
humidity = humidity + humiOffset
}
sendEvent(name: "humidity", value: humidity.setScale(0, BigDecimal.ROUND_HALF_UP), unit: '%')
}
log.info "Temperature: $temperature, Humidity: $humidity"
}
def pollInterval() {
return pollInterval.isNumber() ? pollInterval : defaultPollInterval()
}
def defaultPollInterval() {
return 3 // minutes
}
Still stuck with offset values.
FYI. I offset the temp 2 deg and the humidity -2. Would a neg number be an issue?
Same error message.
Have you tried two positive numbers as a test?
I just tried using negative values for the offsets and everything works fine for me. Are you sure you updated the code correctly?
Previously I was able to reproduce the error messages you showed. Now, they are gone.
I must have had a problem with saving new version. Looks like it will work. I changed offset values and they update with no errors.
Will these offsets I input from a device only offset that device or will it affect any device using this driver? I have several of these Temp and Humidity sensors. If so, I will create copies of the driver with unique names for each device.
It will only impact that specific device. Each of your devices can have their own offsets. No need for multiple copies of the driver.