diff --git a/systems/LoutreOS/services.nix b/systems/LoutreOS/services.nix index 0a095c4..1637006 100644 --- a/systems/LoutreOS/services.nix +++ b/systems/LoutreOS/services.nix @@ -240,16 +240,27 @@ in home-assistant = { enable = true; - # package = pkgs.home-assistant.override { - # extraPackages = ps: with ps; [ aiohttp-cors netdisco zeroconf ]; - # }; config = { - default_config = null; + homeassistant = { + elevation = 143; + }; + influxdb = null; + config = null; + frontend = null; + history = null; + logbook = null; + map = null; + mobile_app = null; + person = null; + script = null; + sun = null; + system_health = null; yeelight.devices = { "10.40.249.0".name = "Chambre"; "10.40.249.1".name = "Bureau"; "10.40.249.2".name = "Cuisine"; }; + esphome = null; light = [ { platform = "group"; @@ -266,6 +277,41 @@ in host = "10.30.0.1"; } ]; + tplink.switch = [ + { host = "10.30.50.7"; } + ]; + sensor = [ + { + platform = "template"; + sensors = { + serveur_amps = { + friendly_name_template = "{{ states.switch.serveur.name}} Current"; + value_template = ''{{ states.switch.serveur.attributes["current_a"] | float }}''; + unit_of_measurement = "A"; + }; + serveur_watts = { + friendly_name_template = "{{ states.switch.serveur.name}} Current Consumption"; + value_template = ''{{ states.switch.serveur.attributes["current_power_w"] | float }}''; + unit_of_measurement = "W"; + }; + serveur_total_kwh = { + friendly_name_template = "{{ states.switch.serveur.name}} Total Consumption"; + value_template = ''{{ states.switch.serveur.attributes["total_energy_kwh"] | float }}''; + unit_of_measurement = "kWh"; + }; + serveur_volts = { + friendly_name_template = "{{ states.switch.serveur.name}} Voltage"; + value_template = ''{{ states.switch.serveur.attributes["voltage"] | float }}''; + unit_of_measurement = "V"; + }; + serveur_today_kwh = { + friendly_name_template = "{{ states.switch.serveur.name}} Today's Consumption"; + value_template = ''{{ states.switch.serveur.attributes["today_energy_kwh"] | float }}''; + unit_of_measurement = "kWh"; + }; + }; + } + ]; switch = [ { platform = "wake_on_lan"; @@ -275,14 +321,71 @@ in broadcast_address = "10.30.255.255"; } ]; - automation = [ + scene = [ + { + name = "Movie"; + icon = "mdi:movie-open"; + entities = { + "light.salon" = { + state = "on"; + xy_color = [0.299 0.115]; + brightness = 50; + }; + "light.bande_led_tv" = { + state = "on"; + effect = "Movie"; + brightness = 180; + }; + "light.bande_led_bureau" = { + state = "on"; + xy_color = [0.299 0.115]; + brightness = 130; + }; + }; + } + { + name = "Home"; + icon = "mdi:home"; + entities = { + "light.salon" = { + state = "on"; + kelvin = 2700; + brightness = 255; + }; + }; + } + { + name = "Night"; + icon = "mdi:weather-night"; + entities = { + "light.salon" = { + state = "off"; + }; + "light.bande_led_tv" = { + state = "off"; + }; + "light.bande_led_bureau" = { + state = "off"; + }; + "light.chambre" = { + state = "on"; + kelvin = 1900; + brightness = 50; + }; + }; + } + ]; + automation = let + min_sun_elevation = 4; + in [ { alias = "Aziz lumière"; trigger = [ { - platform = "sun"; - event = "sunset"; - offset = "-01:00:00"; + platform = "numeric_state"; + entity_id = "sun.sun"; + value_template = "{{ state.attributes.elevation }}"; + below = min_sun_elevation; } { platform = "state"; @@ -297,14 +400,12 @@ in state = "home"; } { - condition = "time"; - after = "16:00:00"; - before = "23:00:00"; + condition = "template"; + value_template = "{{ state_attr('sun.sun', 'elevation') < ${toString min_sun_elevation} }}"; } ]; action = { - service = "light.turn_on"; - entity_id = "light.salon"; + scene = "scene.home"; }; } {