|
@@ -13,24 +13,42 @@ got EVENT_STATE_CHANGED with kwargs=
|
|
}
|
|
}
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
+"""
|
|
|
|
+monitor_the_light_mode_selector() kwargs=
|
|
|
|
+{'trigger_type': 'state',
|
|
|
|
+'var_name': 'input_select.light_mode',
|
|
|
|
+'value': 'Morning',
|
|
|
|
+'old_value': 'No action',
|
|
|
|
+'context': <homeassistant.core.Context object at 0x7f3b26bff640>}
|
|
|
|
+"""
|
|
|
|
+#@state_trigger("input_boolean.christmas")
|
|
|
|
+#def a_test_for_monitor_the_light_mode_selector(value=None, old_value=None):
|
|
|
|
+#def a_test_for_monitor_the_light_mode_selector(**kwargs):
|
|
|
|
+ #log.info(f"a_test_for_monitor_the_light_mode_selector() kwargs={kwargs}")
|
|
|
|
+ #log.info(f"a_test_for_monitor_the_light_mode_selector() {value} {old_value}")
|
|
|
|
+ #log.info(f"Value:{input_boolean.christmas} Type:" + str( type(input_boolean.christmas) ))
|
|
|
|
+ #if( input_boolean.christmas == 'on' ): log.info("ON")
|
|
|
|
+ #if( input_boolean.christmas == 'off' ): log.info("OFF")
|
|
|
|
+ #isChristmas = True if input_boolean.christmas == 'on' else False
|
|
|
|
+ #log.info("BooL: " + str(x))
|
|
|
|
|
|
"""
|
|
"""
|
|
Also, please don't set a state variable inside a function that is trigged by EVENT_STATE_CHANGED,
|
|
Also, please don't set a state variable inside a function that is trigged by EVENT_STATE_CHANGED,
|
|
or make a service call that is triggered by EVENT_CALL_SERVICE, unless the trigger condition is False
|
|
or make a service call that is triggered by EVENT_CALL_SERVICE, unless the trigger condition is False
|
|
in those cases. Otherwise bad things will happen...
|
|
in those cases. Otherwise bad things will happen...
|
|
"""
|
|
"""
|
|
-@event_trigger(EVENT_CALL_SERVICE, "domain == 'scene' and service == 'turn_on'")
|
|
|
|
-def monitor_scene_service_events(domain=None, service=None, service_data=None):
|
|
|
|
- log.info(f"Scene activated: >{service_data['entity_id']}<")
|
|
|
|
- if( service_data['entity_id'] == 'scene.test_scene_a'):
|
|
|
|
- log.info("Yes. It's A")
|
|
|
|
- elif( service_data['entity_id'] == 'scene.test_scene_b'):
|
|
|
|
- log.info("Yes. It's B")
|
|
|
|
|
|
+#@event_trigger(EVENT_CALL_SERVICE, "domain == 'scene' and service == 'turn_on'")
|
|
|
|
+#def monitor_scene_service_events(domain=None, service=None, service_data=None):
|
|
|
|
+# log.info(f"Scene activated: >{service_data['entity_id']}<")
|
|
|
|
+# if( service_data['entity_id'] == 'scene.test_scene_a'):
|
|
|
|
+# log.info("Yes. It's A")
|
|
|
|
+# elif( service_data['entity_id'] == 'scene.test_scene_b'):
|
|
|
|
+# log.info("Yes. It's B")
|
|
|
|
|
|
@state_trigger("input_select.light_mode")
|
|
@state_trigger("input_select.light_mode")
|
|
-def monitor_service_calls(value=None):
|
|
|
|
|
|
+def monitor_light_mode_selector(value=None, old_value=None):
|
|
if not value is None:
|
|
if not value is None:
|
|
- log.info(f"Light state change to: {value}")
|
|
|
|
|
|
+ log.info(f"Light state change to: {value}, old value: {old_value}")
|
|
if value == 'All on':
|
|
if value == 'All on':
|
|
log.info("Go to All on")
|
|
log.info("Go to All on")
|
|
pyscript.state_goto_all_on()
|
|
pyscript.state_goto_all_on()
|
|
@@ -43,6 +61,11 @@ def monitor_service_calls(value=None):
|
|
elif value == 'Windows':
|
|
elif value == 'Windows':
|
|
log.info("Go to Windows")
|
|
log.info("Go to Windows")
|
|
pyscript.state_goto_window()
|
|
pyscript.state_goto_window()
|
|
|
|
+ elif value == 'Re-trigger':
|
|
|
|
+ log.info("Re-trigger to be done here")
|
|
|
|
+ # Set mode the the previous mode
|
|
|
|
+ input_select.light_mode = old_value
|
|
|
|
+
|
|
else:
|
|
else:
|
|
log.info("Light state was None")
|
|
log.info("Light state was None")
|
|
|
|
|
|
@@ -73,7 +96,8 @@ def handleWallButtonPressed():
|
|
@service
|
|
@service
|
|
def state_goto_all_on():
|
|
def state_goto_all_on():
|
|
task.unique('state_goto_py')
|
|
task.unique('state_goto_py')
|
|
- log.info(f"********* ALL ON *********** State: " + input_select.light_mode )
|
|
|
|
|
|
+ isChristmas = True if input_boolean.christmas == 'on' else False
|
|
|
|
+ log.info(f"********* ALL ON *********** State:{input_select.light_mode} Jul:{isChristmas}")
|
|
light.turn_on(entity_id='light.tradfri_bulb') # Stora flyglampan
|
|
light.turn_on(entity_id='light.tradfri_bulb') # Stora flyglampan
|
|
light.turn_on(entity_id='light.hall_inner', brightness=38, color_temp_kelvin=3800)
|
|
light.turn_on(entity_id='light.hall_inner', brightness=38, color_temp_kelvin=3800)
|
|
light.turn_on(entity_id='light.hall_door', brightness=38, color_temp_kelvin=3800)
|
|
light.turn_on(entity_id='light.hall_door', brightness=38, color_temp_kelvin=3800)
|
|
@@ -88,6 +112,9 @@ def state_goto_all_on():
|
|
#task.sleep(0.5)
|
|
#task.sleep(0.5)
|
|
light.turn_on(entity_id='light.liv_room_corner_lamp',brightness='1')
|
|
light.turn_on(entity_id='light.liv_room_corner_lamp',brightness='1')
|
|
task.sleep(0.5)
|
|
task.sleep(0.5)
|
|
|
|
+ if( isChristmas ):
|
|
|
|
+ light.turn_on(entity_id=' light.main_button_4') # Christmas lights
|
|
|
|
+ task.sleep(0.5)
|
|
|
|
|
|
pyscript.kitchen_worklights_button_trigger()
|
|
pyscript.kitchen_worklights_button_trigger()
|
|
#pyscript.handle_bedroom_light() # Temp disable when high energy prices
|
|
#pyscript.handle_bedroom_light() # Temp disable when high energy prices
|
|
@@ -96,10 +123,14 @@ def state_goto_all_on():
|
|
@service
|
|
@service
|
|
def state_goto_window():
|
|
def state_goto_window():
|
|
task.unique('state_goto_py')
|
|
task.unique('state_goto_py')
|
|
- log.info(f"********* WINDOW *********** State: " + input_select.light_mode )
|
|
|
|
|
|
+ isChristmas = True if input_boolean.christmas == 'on' else False
|
|
|
|
+ log.info(f"********* WINDOW *********** State:{input_select.light_mode} Jul:{isChristmas}")
|
|
light.turn_off(entity_id='light.tradfri_bulb')
|
|
light.turn_off(entity_id='light.tradfri_bulb')
|
|
switch.turn_on(entity_id='switch.koksfonster')
|
|
switch.turn_on(entity_id='switch.koksfonster')
|
|
- switch.turn_off(entity_id='switch.matsal_altandorr')
|
|
|
|
|
|
+ if( isChristmas ):
|
|
|
|
+ switch.turn_on(entity_id='switch.matsal_altandorr')
|
|
|
|
+ else:
|
|
|
|
+ switch.turn_off(entity_id='switch.matsal_altandorr')
|
|
switch.turn_off(entity_id='switch.matsal_piano')
|
|
switch.turn_off(entity_id='switch.matsal_piano')
|
|
light.turn_off(entity_id='light.hall_inner')
|
|
light.turn_off(entity_id='light.hall_inner')
|
|
light.turn_off(entity_id='light.hall_door')
|
|
light.turn_off(entity_id='light.hall_door')
|
|
@@ -107,10 +138,13 @@ def state_goto_window():
|
|
switch.turn_off(entity_id='switch.sovrum')
|
|
switch.turn_off(entity_id='switch.sovrum')
|
|
|
|
|
|
for x in range(2):
|
|
for x in range(2):
|
|
- light.turn_off(entity_id='light.liv_room_table_lamp')
|
|
|
|
- task.sleep(0.5)
|
|
|
|
|
|
+ #light.turn_off(entity_id='light.liv_room_table_lamp')
|
|
|
|
+ #task.sleep(0.5)
|
|
light.turn_off(entity_id='light.liv_room_corner_lamp')
|
|
light.turn_off(entity_id='light.liv_room_corner_lamp')
|
|
task.sleep(0.5)
|
|
task.sleep(0.5)
|
|
|
|
+ if( isChristmas ):
|
|
|
|
+ light.turn_on(entity_id=' light.main_button_4') # Christmas lights
|
|
|
|
+ task.sleep(0.5)
|
|
|
|
|
|
pyscript.kitchen_worklights_button_trigger()
|
|
pyscript.kitchen_worklights_button_trigger()
|
|
#pyscript.handle_bedroom_light()
|
|
#pyscript.handle_bedroom_light()
|
|
@@ -118,11 +152,15 @@ def state_goto_window():
|
|
@service
|
|
@service
|
|
def state_goto_morning():
|
|
def state_goto_morning():
|
|
task.unique('state_goto_py')
|
|
task.unique('state_goto_py')
|
|
- log.info(f"********* MORNING *********** State: " + str(input_select.light_mode) )
|
|
|
|
|
|
+ isChristmas = True if input_boolean.christmas == 'on' else False
|
|
|
|
+ log.info(f"********* MORNING *********** State:{input_select.light_mode} Jul:{isChristmas}")
|
|
light.turn_off(entity_id='light.tradfri_bulb')
|
|
light.turn_off(entity_id='light.tradfri_bulb')
|
|
switch.turn_on(entity_id='switch.matsal_altandorr')
|
|
switch.turn_on(entity_id='switch.matsal_altandorr')
|
|
switch.turn_off(entity_id='switch.matsal_piano')
|
|
switch.turn_off(entity_id='switch.matsal_piano')
|
|
- switch.turn_off(entity_id='switch.koksfonster')
|
|
|
|
|
|
+ if( isChristmas ):
|
|
|
|
+ switch.turn_on(entity_id='switch.koksfonster')
|
|
|
|
+ else:
|
|
|
|
+ switch.turn_off(entity_id='switch.koksfonster')
|
|
light.turn_off(entity_id='light.hall_inner')
|
|
light.turn_off(entity_id='light.hall_inner')
|
|
light.turn_on(entity_id='light.hall_door', brightness=25, color_temp_kelvin=2570)
|
|
light.turn_on(entity_id='light.hall_door', brightness=25, color_temp_kelvin=2570)
|
|
light.turn_off(entity_id='light.rislampa')
|
|
light.turn_off(entity_id='light.rislampa')
|
|
@@ -132,6 +170,9 @@ def state_goto_morning():
|
|
#light.turn_on(entity_id='light.liv_room_corner_lamp',brightness='1')
|
|
#light.turn_on(entity_id='light.liv_room_corner_lamp',brightness='1')
|
|
light.turn_off(entity_id='light.liv_room_corner_lamp')
|
|
light.turn_off(entity_id='light.liv_room_corner_lamp')
|
|
task.sleep(0.5)
|
|
task.sleep(0.5)
|
|
|
|
+ if( isChristmas ):
|
|
|
|
+ light.turn_off(entity_id=' light.main_button_4') # Christmas lights
|
|
|
|
+ task.sleep(0.5)
|
|
|
|
|
|
pyscript.kitchen_worklights_button_trigger()
|
|
pyscript.kitchen_worklights_button_trigger()
|
|
#pyscript.handle_bedroom_light()
|
|
#pyscript.handle_bedroom_light()
|
|
@@ -139,7 +180,8 @@ def state_goto_morning():
|
|
@service
|
|
@service
|
|
def state_goto_all_off():
|
|
def state_goto_all_off():
|
|
task.unique('state_goto_py')
|
|
task.unique('state_goto_py')
|
|
- log.info(f"********* ALL OFF *********** State: " + input_select.light_mode )
|
|
|
|
|
|
+ isChristmas = True if input_boolean.christmas == 'on' else False
|
|
|
|
+ log.info(f"********* ALL OFF *********** State:{input_select.light_mode} Jul:{isChristmas}")
|
|
light.turn_off(entity_id='light.tradfri_bulb')
|
|
light.turn_off(entity_id='light.tradfri_bulb')
|
|
light.turn_off(entity_id='light.hall_inner')
|
|
light.turn_off(entity_id='light.hall_inner')
|
|
light.turn_off(entity_id='light.hall_door')
|
|
light.turn_off(entity_id='light.hall_door')
|
|
@@ -155,6 +197,10 @@ def state_goto_all_off():
|
|
#task.sleep(0.5)
|
|
#task.sleep(0.5)
|
|
light.turn_off(entity_id='light.liv_room_corner_lamp')
|
|
light.turn_off(entity_id='light.liv_room_corner_lamp')
|
|
task.sleep(0.5)
|
|
task.sleep(0.5)
|
|
|
|
+ if( isChristmas ):
|
|
|
|
+ light.turn_off(entity_id=' light.main_button_4') # Christmas lights
|
|
|
|
+ task.sleep(0.5)
|
|
|
|
+
|
|
input_boolean.movie_mode = 'off'
|
|
input_boolean.movie_mode = 'off'
|
|
pyscript.kitchen_worklights_button_trigger()
|
|
pyscript.kitchen_worklights_button_trigger()
|
|
|
|
|