diff --git a/hosts/fw/modules/home-assistant/locks.nix b/hosts/fw/modules/home-assistant/locks.nix index 2378d51..aa14f1d 100644 --- a/hosts/fw/modules/home-assistant/locks.nix +++ b/hosts/fw/modules/home-assistant/locks.nix @@ -1,4 +1,9 @@ -{ +let + devices = [ + "device_tracker.dominiks_iphone" + "device_tracker.dominiks_mp01" + ]; +in { services.home-assistant.extraComponents = [ "nuki" ]; @@ -9,9 +14,7 @@ mode = "restart"; trigger = { platform = "state"; - entity_id = [ - "device_tracker.dominiks_iphone" - ]; + entity_id = devices; from = "not_home"; to = "home"; }; diff --git a/hosts/fw/modules/home-assistant/multimedia.nix b/hosts/fw/modules/home-assistant/multimedia.nix index 5bac9b6..4c932e1 100644 --- a/hosts/fw/modules/home-assistant/multimedia.nix +++ b/hosts/fw/modules/home-assistant/multimedia.nix @@ -494,6 +494,12 @@ entity_id = "script.turn_on_tv"; }; } + { + service = "media_player.turn_off"; + target = { + entity_id = "media_player.marantz_sr6015"; + }; + } ]; } ]; diff --git a/hosts/fw/modules/home-assistant/music.nix b/hosts/fw/modules/home-assistant/music.nix index ddc5586..2736e61 100644 --- a/hosts/fw/modules/home-assistant/music.nix +++ b/hosts/fw/modules/home-assistant/music.nix @@ -1,10 +1,11 @@ { + services.home-assistant.extraComponents = [ "squeezebox" ]; services.home-assistant.config = { "automation toilet music" = { alias = "toilet music"; trigger = { platform = "state"; - entity_id = "light.toilett_lights"; + entity_id = "light.toilet_switch"; }; action = [ { @@ -13,10 +14,52 @@ entity_id = "media_player.music_toilet_snapcast_client"; }; data = { - is_volume_muted = "{{ trigger.to_state.state == 'off' }}"; + is_volume_muted = "{{ trigger.to_state.state != 'on' }}"; }; } ]; }; + "automation bathroom music" = { + alias = "bathroom music"; + trigger = { + platform = "state"; + entity_id = "light.bathroom_switch"; + }; + action = [ + { + service = "media_player.volume_mute"; + target = { + entity_id = "media_player.music_bathroom_snapcast_client"; + }; + data = { + is_volume_muted = "{{ trigger.to_state.state != 'on' }}"; + }; + } + ]; + }; + "automation piano" = { + alias = "piano"; + trigger = { + platform = "state"; + entity_id = "media_player.music_piano_snapcast_client"; + attribute = "is_volume_muted"; + }; + condition = [ + { + condition = "template"; + value_template = "{{ trigger.from_state.state != 'unavailable' }}"; + } + { + condition = "template"; + value_template = "{{ state_attr('media_player.music_piano_snapcast_client', 'is_volume_muted') == true or state_attr('media_player.music_piano_snapcast_client', 'is_volume_muted') == false }}"; + } + ]; + action = { + service = "switch.turn_on"; + target = { + entity_id = "switch.piano_switch_power"; + }; + }; + }; }; } diff --git a/hosts/fw/modules/home-assistant/snapcast.nix b/hosts/fw/modules/home-assistant/snapcast.nix index 9fc54d6..e745ed5 100644 --- a/hosts/fw/modules/home-assistant/snapcast.nix +++ b/hosts/fw/modules/home-assistant/snapcast.nix @@ -1,31 +1,5 @@ { services.home-assistant = { extraComponents = [ "snapcast" ]; - config = { - "automation piano" = { - alias = "piano"; - trigger = { - platform = "state"; - entity_id = "media_player.music_piano_snapcast_client"; - attribute = "is_volume_muted"; - }; - condition = [ - { - condition = "template"; - value_template = "{{ trigger.from_state.state != 'unavailable' }}"; - } - { - condition = "template"; - value_template = "{{ state_attr('media_player.music_piano_snapcast_client', 'is_volume_muted') == true or state_attr('media_player.music_piano_snapcast_client', 'is_volume_muted') == false }}"; - } - ]; - action = { - service = "switch.turn_on"; - target = { - entity_id = "switch.piano_switch_power"; - }; - }; - }; - }; }; }