Although I recently started working with HA + AppDeamon, I would like to share some small apps that I have so far, and maybe get some feedback (I’m a novice python developer).
App #1: Doorbell notification
Send me a notification when someone presses the doorbell, but don’t notify me after every press. Each notification must have an interval of at least 30 seconds.
doorbell: module: doorbell_notification class: DoorBellNotification sensor: sensor.doorbell
import appdaemon.plugins.hass.hassapi as hass from datetime import datetime, timedelta class DoorBellNotification(hass.Hass): def initialize(self): self.log('initializing') # initialize last_ring variable to avoid extra `If` condition self.last_ring = datetime.now() - timedelta(seconds= 35) self.listen_state(self.on_doorbell_press, self.args["sensor"], new="on") def on_doorbell_press(self, entity, attribute, old, new, kwargs): if self.last_ring < datetime.now() - timedelta(seconds= 30): self.last_ring = datetime.now() self.log('sending notification')
This solution is not final or complete but maybe ca help new members starting with HA+AppDaemon. Suggestions or recommendations to improve the implementation are welcome! (|'m still learning )
Next post: App #2: Smart Light