Hi guys,
I just did my first ever groovy app by following the instructions and example in the Hubitat documentation (Pls see code below). The goal of the script is eventually to become a thermostate based mainly on outside temperature, outside light levels and inside temperature. The script so far works fine as far as it gets values for outside light and outside temperature every time the sensor is sending a chagned value. But, as you can see it is no where near complete. The next hurdle I am working on now is as follows:
- The values sent by the sensors disapears as soon as they are reported. (1) I would like to capture them and store them into variables. (2) I would also like to ping the sensor and get the current value and store that, rather than waiting for the sensor to change. I have read a lot in the documentation and tried lots and lots of variation of getcurrentvalue() and state. but seemingly nothing happens or works. I've also looked at the sample code in the Hubitat official GitHub Archive but I to far back knowledge wise to understand. I tried searching for info regarding handlers and there options but not found anything useful yet. The reason I want to do this is to start building the logic based around the paramter values.
Any and all thoughts appreciated.
Thanks for your time and your patiens
preferences{
page(name: "mainPage", title: "Heat and cooling control", install: true, uninstall: true) {
section("GrundlÀggande parametrar", hideable: true, hidden: true) {
paragraph "VÀrdena nedan styr de brytpunkter dÄ vÀrme alternativt kyla skall slÄs av och
pÄ. Appen anvÀnder en kombination av ljusstyrka och temeratur utomhus och eller
inomhus för att avgöra nÀr en brytpunkt uppnÄtts."
input (name: "outside_light_heating_point_v", type: "integer", title: "Ljusbrytpunkt för
uppvÀrmning (Lux)", required: true, defaultValue: 5000)
input (name: "outside_temp_heating_point_v", type: "integer", title: "Brytpunkt utomhustemperatur för uppvÀrmning (C)", required: true, defaultValue: 10)
input (name: "outside_light_cooling_point_v", type: "integer", title: "Ljusbrytpunkt för kylning (Lux)", required: true, defaultValue: 10000)
input (name: "outside_temp_cooling_point_v", type: "integer", title: "Brytpunkt utomhustemperatur för kylning (C)", required: true, defaultValue: 25)
input (name: "inside_temp_cooling_point_v", type: "integer", title: "Brytpunkt inomhustemperatur för kylning (C)", required: true, defaultValue: 25)
}
section("Temperatursensor", hideable: true, hidden: true) {
paragraph "VÀlj vilken sensor som skall anvÀndas för att mÀta temperaturen"
input "tempSensor", "capability.temperatureMeasurement", title: "Select Temperature Sensor", submitOnChange: true, required: true, multiple: false
}
section("Ljussensor", hideable: true, hidden: true) {
paragraph "VÀlj vilken sensor som skall anvÀndas för att mÀta ljusinflödet"
input "lightSensor", "capability.illuminanceMeasurement", title: "Select Light Sensor",
submitOnChange: true, required: true, multiple: false
}
}
}
def installed() {
log.debug "Heatcontroller 0.2: installed()"
updated()
}
def updated() {
log.debug "Heatcontroller 0.2: updated()"
subscribe(tempSensor, "temperature", tempHandler)
subscribe(lightSensor, "illuminance", lightHandler)
}
def uninstalled() {}
def tempHandler(evt) {
log.debug "Heatcontroller 0.2: tempHandler() called: ${evt.name} is currently ${evt.value}"
}
def lightHandler(evt) {
log.debug "Heatcontroller 0.2: lightHandler() called: ${evt.name} is currently ${evt.value}"
}