73 lines
3.1 KiB
Python
73 lines
3.1 KiB
Python
from ir_helpers import *
|
|
|
|
|
|
@pyscript_compile
|
|
def timed_sleep_f(content, light_off_mins, music_off_mins, shuffle):
|
|
variables = {
|
|
'media_content_id': content,
|
|
'light_off_secs': light_off_mins * 60,
|
|
'music_off_secs': music_off_mins * 60,
|
|
'shuffle': shuffle,
|
|
}
|
|
|
|
async def f():
|
|
await hass.services.async_call('script', 'timed_sleep', variables)
|
|
return f
|
|
|
|
|
|
@state_trigger("switch.tasmota07 == 'on'")
|
|
def foen_auto_off():
|
|
timer.fon_timer.start(duration="00:45:00")
|
|
|
|
|
|
@event_trigger("ir_command_received", "host == 'bedroompi.fritz.box' and repeat_counter == 0")
|
|
def ir_remote_schlafzimmer(button_name=None, **kwargs):
|
|
p = {'player': 'media_player.bedroompi'}
|
|
mapping = {
|
|
**default_ir_light_control('group.bedroom'),
|
|
**default_ir_cover_control('group.bedroom'),
|
|
**default_ir_music_control(**p),
|
|
'btn_1': playlist_f('Good Morning', **p),
|
|
'btn_2': playlist_f('Good Night Long', **p),
|
|
'btn_3': playlist_f('Good Night', **p),
|
|
|
|
'btn_4': playlist_f('Bar Classics', **p),
|
|
'btn_5': playlist_f('Sentimental Moods', **p),
|
|
'btn_6': playlist_f(URLS['spotify_merkliste'], **p),
|
|
|
|
'btn_7': radio_f('BR24', **p),
|
|
'btn_8': radio_f('BR-Klassik', **p),
|
|
'btn_9': playlist_f(URLS['klassik_radio'], **p),
|
|
|
|
'btn_0': radio_f('Bayern 3', **p),
|
|
'key_numeric_pound': radio_f('Bayern 2', **p),
|
|
#'key_numeric_star': lambda: timer.fon_timer.start(duration="00:10:00"),
|
|
|
|
'key_red': scene_f('schlafzimmer_stillen'),
|
|
'key_green': scene_f('schlafzimmer_orange'),
|
|
'key_yellow': scene_f('schlafzimmer_ganz_hell'),
|
|
'key_blue': scene_f('nachtswennallelieberschlafen'),
|
|
|
|
'key_tv': timed_sleep_f(URLS['spotify_rain'], light_off_mins=15, music_off_mins=45, shuffle=True),
|
|
'key_video': timed_sleep_f('Good Night', light_off_mins=15, music_off_mins=45, shuffle=False),
|
|
'key_music': timed_sleep_f(URLS['spotify_rain'], light_off_mins=5, music_off_mins=20, shuffle=True),
|
|
'key_picture': timed_sleep_f('Good Night', light_off_mins=5, music_off_mins=20, shuffle=False)
|
|
}
|
|
if button_name in mapping:
|
|
mapping[button_name]()
|
|
elif button_name == "key_numeric_star": # Foen
|
|
#repeat_one_crossfade(**p)
|
|
#media_player.play_media(media_content_id='Foen', media_content_type='music', entity_id=p['player'])
|
|
#media_player.volume_set(volume_level=60, entity_id=p['player'])
|
|
timer.fon_timer.start(duration="00:10:00")
|
|
elif button_name == 'key_power': # Music & Lights off
|
|
media_player.media_pause(entity_id=p['player'])
|
|
light.turn_off(entity_id='group.bedroom')
|
|
elif button_name == 'key_ok': # Grosser Rollo zu, kleiner halb zu
|
|
cover.schlafzimmer_rollo_gross.close_cover()
|
|
cover_half.set_half(entity_id="cover.schlafzimmer_rollo_klein")
|
|
elif button_name == 'key_mute': # Alles aus ohne draussen & schlafzimmer
|
|
light.turn_off(entity_id='group.all_downstairs_but_bedroom_and_outside')
|
|
elif button_name == 'key_channel': # alles aus ausser schlafzimmer
|
|
light.turn_off(entity_id='group.all_downstairs_but_bedroom')
|