120 lines
4.3 KiB
Python
120 lines
4.3 KiB
Python
@pyscript_compile
|
|
def in_room(room):
|
|
return f"entity_id.startswith('switch.{room}_szene_')"
|
|
|
|
|
|
@event_trigger("short_click", in_room("eingang"))
|
|
@event_trigger("long_click", in_room("eingang"))
|
|
def eingang(entity_id=None, event_type=None):
|
|
long_click = (event_type == "long_click")
|
|
key = {'switch.eingang_szene_2': 'bulb_orange',
|
|
'switch.eingang_szene_3': 'bulb_black',
|
|
'switch.eingang_szene_4': 'key',
|
|
'switch.eingang_szene_5': 'dog'}[entity_id]
|
|
|
|
if key == "bulb_orange":
|
|
light.gang_licht.turn_on()
|
|
light.gang_einganglicht.turn_on()
|
|
if long_click:
|
|
scene.wohnbereich_hell.turn_on()
|
|
elif key == "bulb_black":
|
|
if long_click:
|
|
light.turn_off(entity_id="group.all_downstairs")
|
|
else:
|
|
light.turn_off(entity_id="group.all_downstairs_but_outside")
|
|
|
|
|
|
@event_trigger("short_click", in_room("esszimmer"))
|
|
@event_trigger("long_click", in_room("esszimmer"))
|
|
def esszimmer_gangtuer(entity_id=None, event_type=None):
|
|
key = {'switch.esszimmer_szene_0': 'arrow_down',
|
|
'switch.esszimmer_szene_1': 'arrow_up',
|
|
'switch.esszimmer_szene_2': 'bulb_orange',
|
|
'switch.esszimmer_szene_3': 'bulb_yellow',
|
|
'switch.esszimmer_szene_4': 'cooking_pot', # Herd an/aus in separater Datei
|
|
'switch.esszimmer_szene_5': 'bulb_black'}[entity_id]
|
|
long_click = (event_type == "long_click")
|
|
|
|
if long_click:
|
|
covers = ['cover.kuche_fenster_rollo', 'cover.esszimmer_fenster_rollo']
|
|
else:
|
|
covers = ['group.living_area']
|
|
|
|
if key == "arrow_down":
|
|
cover_half.set_half(entity_id=covers)
|
|
elif key == "arrow_up":
|
|
cover.open_cover(entity_id=covers)
|
|
elif key == "bulb_orange":
|
|
if long_click:
|
|
scene.kuche_essbereich_orange.turn_on()
|
|
else:
|
|
scene.wohnbereich_orange.turn_on()
|
|
elif key == "bulb_yellow":
|
|
if long_click:
|
|
scene.kuche_essbereich_hell.turn_on()
|
|
else:
|
|
scene.wohnbereich_hell.turn_on()
|
|
elif key == "bulb_black":
|
|
if long_click:
|
|
light.essbereich_lichter.turn_off()
|
|
else:
|
|
light.turn_off(entity_id="group.living_area")
|
|
|
|
|
|
@event_trigger("short_click", in_room("wohnzimmer"))
|
|
@event_trigger("long_click", in_room("wohnzimmer"))
|
|
def wohnzimmer_gangtur(entity_id=None, event_type=None):
|
|
long_click = (event_type == "long_click")
|
|
key = {'switch.wohnzimmer_szene_0': 'arrow_down',
|
|
'switch.wohnzimmer_szene_1': 'arrow_up',
|
|
'switch.wohnzimmer_szene_2': 'bulb_orange',
|
|
'switch.wohnzimmer_szene_3': 'bulb_yellow',
|
|
'switch.wohnzimmer_szene_4': 'bulb_blue',
|
|
'switch.wohnzimmer_szene_5': 'bulb_black'}[entity_id]
|
|
|
|
if long_click:
|
|
covers = ['cover.wohnzimmer_fenster_rollo', 'cover.wohnzimmer_terrassentur_rollo']
|
|
else:
|
|
covers = ['group.living_area']
|
|
|
|
if key == "arrow_down":
|
|
cover_half.set_half(entity_id=covers)
|
|
elif key == "arrow_up":
|
|
cover.open_cover(entity_id=covers)
|
|
elif key == "bulb_orange":
|
|
if long_click:
|
|
scene.wohnzimmer_orange.turn_on()
|
|
else:
|
|
scene.wohnbereich_orange.turn_on()
|
|
elif key == "bulb_yellow":
|
|
if long_click:
|
|
scene.wohnzimmer_hell.turn_on()
|
|
else:
|
|
scene.wohnbereich_hell.turn_on()
|
|
elif key == "bulb_blue":
|
|
if long_click:
|
|
scene.wohnzimmer_dunkel.turn_on()
|
|
else:
|
|
scene.wohnbereich_blau_grun.turn_on()
|
|
elif key == "bulb_black":
|
|
if long_click:
|
|
light.wohnzimmer_lichter.turn_off()
|
|
else:
|
|
light.turn_off(entity_id="group.living_area")
|
|
|
|
|
|
@event_trigger("short_click", in_room("wohnzimmer_terrassentur"))
|
|
@event_trigger("long_click", in_room("wohnzimmer_terrassentur"))
|
|
def wohnzimmer_terassentuer(entity_id=None, event_type=None):
|
|
long_click = (event_type == "long_click")
|
|
key = {'switch.wohnzimmer_terrassentur_szene_2': 'teddy',
|
|
'switch.wohnzimmer_terrassentur_szene_3': 'flowers'}[entity_id]
|
|
if key == "teddy":
|
|
if long_click:
|
|
scene.wohnbereich_kuscheln.turn_on()
|
|
elif key == "flowers":
|
|
if long_click:
|
|
light.turn_off(entity_id="light.garten_lichter")
|
|
else:
|
|
scene.garten_savanna.turn_on()
|