Be explicit that an alarm was resolved

This commit is contained in:
Abel Luck 2022-11-30 16:11:09 +00:00
parent 08f5b49b16
commit cbc4b16f8f

View file

@ -34,16 +34,22 @@ def handle_json_notification(payload: Any, body: Any) -> Tuple[str, str]:
subject = payload.get("Subject")
state_value = payload.get("NewStateValue", "unknown")
plain = f"{subject}\n{description}"
if state_value == "ALARM":
color = COLOR_ALARM
elif state_value == "OK":
color = COLOR_OK
else:
color = COLOR_UNKNOWN
formatted = (
f"<strong><font color={color}>{subject}</font></strong>\n<p>{description}</p>"
)
plain = f"{subject}"
formatted = f"<strong><font color={color}>{subject}</font></strong>\n"
if state_value == "OK":
plain += "\n(this alarm has been resolved!)"
formatted += "\n<p>(this alarm has been resolved!)</p>"
else:
plain += "\n{description}"
formatted += f"\n<p>{description}</p>"
return plain, formatted