Created
January 4, 2019 17:07
-
-
Save timcharper/9b81696bd78314f19c3e2c7446d29f47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var long lastNotified = 0 | |
var String lastReceipt | |
rule "Alert for bad air" | |
when | |
Item Master_Air_Pm25 changed or System started | |
then | |
val pm25 = (Master_Air_Pm25.state as Number).intValue | |
logDebug("air-quality", "pm25 = {}", pm25) | |
if ((now.millis - lastNotified) > 3600000) { | |
if (pm25 >= 15) { | |
val message = String::format("Attention, PM2.5 level is %d; Sent command to run HVAC fan", pm25) | |
Nest_Thermostat_FanTimerActive.sendCommand(ON); | |
lastReceipt = sendPushoverMessage( | |
pushoverBuilder(message).withTitle("Indoor PM2.5 alert").withEmergencyPriority()) | |
logInfo("air-quality", "Send message with receipt {}; lastNotified was {}", lastReceipt, lastNotified) | |
lastNotified = now.millis | |
} | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment