Well I thought as it was just about finished it, I’d post the SmartApp that I wrote for this.
Please bear in mind that this is really for my own situation but I thought it might be a useful starting point for other users. (feel free to modify)
This is configured to open the windows a set level due to increased temperature.
e.g.
If a temperature sensor reports a certain temp then open the windows to a pre-configured level (10%-90%)
At a higher temp then open the windows fully
As the room cools then do the opposite at the same temps, finally closing when below a set level
Switch - Optional
If a switch is configured - Only operate when that switch is on.
If the switch is turned off then close the windows and don’t automatically open them again.
Rain Sensor - Optional
If a water (rain?) sensor is configured only operate when this shows 'Dry’
If it starts raining then close the windows (disregard temp settings)
A few minutes after it has stopped raining (when the sensor reports ‘Dry’ then the automation starts again
All of this can be configured for different modes and for different days of the week.
I’ve tested it as best I can and it’s now in daily use but if anyone wants to use it and has suggestions/problems then please let me know
So here it is…
/**
* Updates
* =========
*
* Last Update: 10/05/2017
*
* V1.5 - Added ability to schedule days of the week
* V1.4 - Added ability to enable/disable opening with water sensor AND/OR an override switch
* V1.3 - Added capability to set 'Partially Open' level
* V1.2 - Added capability to enable/disable via water sensor
* V1.1 - Added control switch to enable/disable opening
* V1.0 - Original POC
*
*
*
* Copyright 2017 SecurEndpoint
*
* 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.
*
*
* Temp Controlled Windows V1.5
*
* Author: AJ Parker
*
*
*/
definition(
name: "Temperature Controlled Windows",
namespace: "Cobra",
author: "AJ Parker",
description: "Monitor the temperature and when it drops above or below your Temp setting set the window level.",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo-switch.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo-switch@2x.png"
)
preferences {
section("Which window/vent control relay?") {
input "relay1", "capability.switchLevel" , title: "Select Device", required: true
}
section("Enable/Disable Switch") {
paragraph "Select the switch to to enable/disable"
input "switch1", "capability.switch", title: "Select switch if using this method to enable/disable", required: false
}
section("Enable/Disable Rain Sensor") {
paragraph "Select the water sensor to enable/disable"
input "water1", "capability.waterSensor", title: "Select Sensor if using this method to enable/disable", required: false
}
section("On Which Days") {
input "days", "enum", title: "Select Days of the Week", required: true, multiple: true, options: ["Monday": "Monday", "Tuesday": "Tuesday", "Wednesday": "Wednesday", "Thursday": "Thursday", "Friday": "Friday", "Saturday": "Saturday", "Sunday": "Sunday"]
}
section("Monitor the temperature...") {
input "temperatureSensor1", "capability.temperatureMeasurement", title: "Select Sensor", required: true
}
section("Below this temperature the window/vent should be 100% Closed") {
input "temperature1", "number", title: "Temperature?" , required: true
}
section("Above this temperature window/vent should be Partially Open - MUST be between fully open setting and fully closed setting") {
input "temperature3", "number", title: "Temperature?" , required: true
}
section("Above this temperature the window/vent should be 100% Open") {
input "temperature2", "number", title: "Temperature?" , required: true
}
section("Patially Open Level") {
input(name:"halfLevel", type:"enum", title: "% Open", required: true, options: [10,20,30,40,50,60,70,80,90])
}
}
// Processes & Handlers
def installed() {
log.debug "Installed with settings: ${settings}"
initialise()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialise()
}
def initialise() {
subscribe(temperatureSensor1, "temperature", temperatureHandler)
subscribe(switch1, "switch", switchHandler)
subscribe(water1, "water", rainHandler)
}
def switchHandler(evt) {
state.currS1 = evt.value // Note: Optional if switch is used to control action
log.debug "$switch1 = $evt.value"
if (state.currS1 == "off") {
log.info "$switch1: $evt.value, Disabling automatic control"
}
if (state.currS1 == "on") {
log.info "$switch1: $evt.value, Enabling automatic control"
}
}
def rainHandler(evt) {
state.currS2 = evt.value // Note: Optional if Rain sensor is used to control actions
log.debug "$water1 = $evt.value"
if (state.currS2 == "wet") {
def myLevel = 0
log.warn "$water1: $evt.value, It's raining! Setting $relay1 to $myLevel"
relay1.setLevel(myLevel)
}
if (state.currS2 == "dry") {
log.info "$water1: $evt.value, Enabling automatic control"
}
}
// Actions on temperature change (dependant upon switch & sensor settings)
def temperatureHandler(evt) {
log.info "temperature: $evt.value, $evt"
def df = new java.text.SimpleDateFormat("EEEE")
df.setTimeZone(location.timeZone)
def day = df.format(new Date())
def dayCheck = days.contains(day)
if (dayCheck) {
log.info "Today is $day so we can proceed as it is one of the configured days of operation"
if (state.currS1 == "off") {
log.info "$switch1 is off so automatic change is not enabled - Not moving $relay1"
}
if (state.currS2 == "wet") {
log.info "$water: $evt.value, so automatic change is not enabled - Not moving $relay1"
}
else
{
def fullClose = temperature1
def fullOpen = temperature2
def halfOpen = temperature3
if (evt.doubleValue <= fullClose) {
def myLevel = 0
relay1.setLevel(myLevel)
log.trace "temperature: $evt.value, Setting $relay1 to $myLevel"
}
else if (evt.doubleValue >= fullOpen) {
def myLevel = 100
log.trace "temperature: $evt.value, Setting $relay1 to $myLevel"
relay1.setLevel(myLevel)
}
else if (evt.doubleValue >= halfOpen) {
if (evt.doubleValue < fullOpen) {
def myLevel = halfLevel
log.trace "temperature: $evt.value, Setting $relay1 to $myLevel"
relay1.setLevel(myLevel)
}
}
else if (evt.doubleValue < halfOpen) {
if (evt.doubleValue > fullclose) {
def myLevel = 50
log.trace "temperature: $evt.value, Setting $relay1 to $myLevel"
relay1.setLevel(myLevel)
}
}
}
}
}
Comments & suggestions welcome 