Skip to content

Instantly share code, notes, and snippets.

@timcharper
Created January 4, 2019 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timcharper/9b81696bd78314f19c3e2c7446d29f47 to your computer and use it in GitHub Desktop.
Save timcharper/9b81696bd78314f19c3e2c7446d29f47 to your computer and use it in GitHub Desktop.
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