FYI - I had to modify your app + Driver to get it to work, as your namespaces were clashing (or perhaps I grabbed the wrong versions of these from other posts).
Here's the final code that actually worked for me. Let me know if you have an updated version somewhere and I'll remove these.
Thank you once again for this app, this is fantastic, specially paired with Hubigraphs.
App:
/*
Dew Point App V003
2020-07-05
Think we don't need to store the lastTEMP and lastHUMID. We can just read them when we need to make a calc.
2020-07-20 (open) added Virtual DewPoint Calc device to display the below results.
*/
definition(
name: "DEW Point Calculator",
namespace: "JohnRob",
author: "JohnRob",
description: "DEW Point Calculator",
category: "Convenience",
iconUrl: "",
iconX2Url: "")
preferences {
page(name: "mainPage")
}
def mainPage() {
dynamicPage(name: "mainPage", title: " ", install: true, uninstall: true) {
section {
//log.debug (" 25 beginning of section")
input "thisName", "text", title: "Name this DEW Point Calculator", submitOnChange: true
if(thisName) app.updateLabel("$thisName")
input "tempSensor", "capability.temperatureMeasurement", title: "Select Temperature Sensor", submitOnChange: true, required: true, multiple: false
input "humidSensor", "capability.relativeHumidityMeasurement", title: "Select Humidity Sensor", submitOnChange: true, required: true, multiple: false
//log.debug (" 30 end of section")
} // section
} // dymanicPage
} // mainPage
def installed() {
initialize()
}
def updated() {
unsubscribe()
initialize()
}
def initialize() {
//log.debug (" 45 begin initialize")
def dewpointDev = getChildDevice("DEWPoint_${app.id}")
if(!dewpointDev) dewpointDev = addChildDevice("JohnRob", "Virtual DewPoint", "DEWPoint_${app.id}", null, [label: thisName, name: thisName])
dewpointDev.setDewPoint(0)
subscribe(tempSensor, "temperature", handlerTEMP)
subscribe(humidSensor, "humidity", handlerHUMID)
state.lastHUMID = 50 // these are in the app and will not display in the child
state.lastTEMP = 50 // 50/50 DEWPoint = 32
}
def calcDEW() {
def dewpointDev = getChildDevice("DEWPoint_${app.id}")
//log.debug " 56 state.lastTEMP ${state.lastTEMP}"
//log.debug " 57 state.lastHUMID ${state.lastHUMID}"
operandHUMID = state.lastHUMID.toDouble()
operandTEMP = state.lastTEMP.toDouble()
def dewPoint = (operandTEMP - (9 / 25) * (100 - operandHUMID))
//log.debug " 62 dewPoint = ${dewPoint}"
dewpointDev.setDewPoint(dewPoint.toInteger())
//return
}
def handlerHUMID(evt) {
state.lastHUMID = evt.value
//log.debug " 65 last Humidity = ${evt.value}"
calcDEW()
}
def handlerTEMP(evt) {
state.lastTEMP = evt.value
//log.debug " 71 last Temperature = ${evt.value}"
calcDEW()
}
// --- eof ---
Virtual Device:
// V0.01 Virtual Dew Point Device
metadata {
definition (name: "Virtual DewPoint", namespace: "JohnRob", author: "several") {
capability "Sensor"
command "setDewPoint", ["NUMBER"] // this will be a method. [] may cause an input box to be created must test.
attribute "DewPoint", "Number" // this will go into the Hub database
}
preferences { // These become entries in the "device" page to ask us for our preferences!
input name: "txtEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: true
}
}
def installed() {
log.warn "installed..."
setDewPoint(0)
}
def updated() {
log.info "updated..."
log.warn "description logging is: ${txtEnable == true}"
}
def parse(String description) {
} // basically useless. Included because it is included in the template.
def setDewPoint(dewpoint) {
// log.debug " 29 dewpoint = ${dewpoint}"
def descriptionText = "${device.displayName} was set to $dewpoint"
if (txtEnable) log.info "${descriptionText}"
sendEvent(name: "DewPoint", value: dewpoint, unit: "°F", descriptionText: descriptionText)
}