Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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