esphome
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import appdaemon.plugins.hass.hassapi as hass
|
||||
|
||||
class Noolite(hass.Hass):
|
||||
brightness = 25
|
||||
brightness = 40
|
||||
force = False
|
||||
|
||||
def initialize(self):
|
||||
self.run_at_sunrise(self.sunrise_cb)
|
||||
self.run_at_sunset(self.sunset_cb)
|
||||
# self.run_at_sunset(self.sunset_cb)
|
||||
self.listen_state(self.light_change, "group.mainroom_light")
|
||||
self.listen_event(self.away_mode, "away_mode")
|
||||
|
||||
@@ -15,7 +15,7 @@ class Noolite(hass.Hass):
|
||||
|
||||
def light_change(self, entity, attribute, old, new, kwargs):
|
||||
sun_down = self.sun_down()
|
||||
if new == "off" and (sun_down or self.force):
|
||||
if new == "off" and (sun_down or self.force) and self.somebody_home():
|
||||
self.noolite_on(self.brightness)
|
||||
else:
|
||||
self.noolite_off()
|
||||
@@ -29,7 +29,18 @@ class Noolite(hass.Hass):
|
||||
self.turn_on(self.args['entity_id'], brightness=self.brightness)
|
||||
|
||||
def sunset_cb(self, kwargs):
|
||||
if not self.somebody_home():
|
||||
return
|
||||
self.noolite_on(self.brightness)
|
||||
|
||||
def somebody_home(self):
|
||||
if 'ha_panel' not in self.args:
|
||||
return True
|
||||
ha_panel_state = self.get_state(self.args['ha_panel'])
|
||||
if ha_panel_state == 'armed_away':
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def sunrise_cb(self, kwargs):
|
||||
self.noolite_off()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
salt_lamp:
|
||||
module: salt_lamp
|
||||
class: Noolite
|
||||
entity_id: light.salt_lamp
|
||||
entity_id: light.salt_lamp
|
||||
ha_panel: alarm_control_panel.ha_alarm
|
||||
|
||||
Reference in New Issue
Block a user