diff --git a/systems/LoutreOS/services.nix b/systems/LoutreOS/services.nix index 25a8ed4..8822d0f 100644 --- a/systems/LoutreOS/services.nix +++ b/systems/LoutreOS/services.nix @@ -277,6 +277,7 @@ in "10.40.249.1".name = "Bureau"; "10.40.249.2".name = "Cuisine"; }; + zha = null; esphome = null; light = [ { @@ -400,7 +401,27 @@ in ]; automation = let min_sun_elevation = 4; + + switch_chambre = { + domain = "zha"; + platform = "device"; + device_id = "3329ecdcad244e5e8fc0f4b96d52ffe1"; + }; + + switch_entree = { + domain = "zha"; + platform = "device"; + device_id = "7cd814190ec543dba76a7aa7e7996c41"; + }; + + remote = { + domain = "zha"; + platform = "device"; + device_id = "d1230b76264e483388a8fdaad4f44143"; + }; in [ + # ENTREE + { alias = "Aziz lumière"; trigger = [ @@ -410,11 +431,6 @@ in value_template = "{{ state.attributes.elevation }}"; below = min_sun_elevation; } - { - platform = "state"; - entity_id = "person.paul"; - to = "home"; - } ]; condition = [ { @@ -427,27 +443,34 @@ in condition = "template"; value_template = "{{ state_attr('sun.sun', 'elevation') < ${toString min_sun_elevation} }}"; } - # All lights off - { - condition = "template"; - value_template = '' - {% set domain = 'light' %} - {% set state = 'off' %} - {{ states[domain] | count == states[domain] | selectattr('state','eq', state) | list | count }} - ''; - } ]; action = { scene = "scene.home"; }; } { - alias = "Adios"; + alias = "Aziz lumière switch"; trigger = { - platform = "state"; - entity_id = "person.paul"; - to = "not_home"; + type = "remote_button_short_press"; + subtype = "turn_on"; + } // switch_entree; + action = { + scene = "scene.home"; }; + } + { + alias = "Adios"; + trigger = [ + { + platform = "state"; + entity_id = "person.paul"; + to = "not_home"; + } + ({ + type = "remote_button_short_press"; + subtype = "turn_off"; + } // switch_entree) + ]; action = [ { service = "light.turn_off"; @@ -459,6 +482,129 @@ in } ]; } + + # REMOTE + + { + alias = "Button toggle"; + trigger = { + type = "remote_button_short_press"; + subtype = "turn_on"; + } // remote; + action = { + choose = { + conditions = { + condition = "template"; + value_template = '' + {% set domain = 'light' %} + {% set state = 'off' %} + {{ states[domain] | count == states[domain] | selectattr('state','eq',state) | list | count }} + ''; + }; + sequence = { + scene = "scene.home"; + }; + }; + default = { + service = "light.turn_off"; + entity_id = "all"; + }; + }; + } + { + alias = "Button scene movie"; + trigger = { + type = "remote_button_short_press"; + subtype = "right"; + } // remote; + action = { + scene = "scene.movie"; + }; + } + { + alias = "Button scene home"; + trigger = { + type = "remote_button_short_press"; + subtype = "left"; + } // remote; + action = { + scene = "scene.home"; + }; + } + { + alias = "Button light up"; + trigger = { + type = "remote_button_short_press"; + subtype = "dim_up"; + } // remote; + action = { + service = "light.turn_on"; + entity_id = "light.salon"; + data = { + brightness_step = 25; + }; + }; + } + { + alias = "Button light down"; + trigger = { + type = "remote_button_short_press"; + subtype = "dim_down"; + } // remote; + action = { + service = "light.turn_on"; + entity_id = "light.salon"; + data = { + brightness_step = -25; + }; + }; + } + + # CHAMBRE + + { + alias = "Button scene night"; + trigger = { + type = "remote_button_short_press"; + subtype = "turn_on"; + } // switch_chambre; + action = { + scene = "scene.night"; + }; + } + { + alias = "Button scene dodo"; + trigger = { + type = "remote_button_short_press"; + subtype = "turn_off"; + } // switch_chambre; + action = { + service = "light.turn_off"; + entity_id = "all"; + }; + } + { + alias = "Button scene lumière chambre ON"; + trigger = { + type = "remote_button_long_press"; + subtype = "dim_up"; + } // switch_chambre; + action = { + service = "light.turn_on"; + entity_id = "light.chambre"; + }; + } + { + alias = "Button scene lumière chambre OFF"; + trigger = { + type = "remote_button_long_press"; + subtype = "dim_down"; + } // switch_chambre; + action = { + service = "light.turn_off"; + entity_id = "light.chambre"; + }; + } ]; }; };