diff --git a/configs/pepe/home-assistant.nix b/configs/pepe/home-assistant.nix index aeed7f4..8047a2b 100644 --- a/configs/pepe/home-assistant.nix +++ b/configs/pepe/home-assistant.nix @@ -4,13 +4,13 @@ in { imports = [ #./home-assistant/chaospott.nix - #./home-assistant/holiday.nix #./home-assistant/mpd.nix - ./home-assistant/sonoff.nix - ./home-assistant/mqtt.nix - #./home-assistant/dayOfWeek.nix #./home-assistant/timer.nix ./home-assistant/kodi.nix + ./home-assistant/mqtt.nix + ./home-assistant/sonoff.nix + ./home-assistant/weather.nix + ./home-assistant/workday.nix ./home-assistant/zigbee2mqtt.nix ]; @@ -82,6 +82,7 @@ in { # entity_id = "group.kitchen"; # }; #} + ]; group = { @@ -116,7 +117,6 @@ in { name = "Not Used"; view = false; }; - view_rooms = { name = "Räume"; view = true; @@ -128,7 +128,6 @@ in { "group.tv" ]; }; - view_overview = { name = "Übersicht"; view = true; @@ -143,33 +142,6 @@ in { script.turn_all_on.sequence = [ ]; - sensor = [ - # Weather prediction - { - platform = "zamg"; - name = "Weather"; - } - ]; - - # todo: add holidays package to home-assiatnt - binary_sensor = [ - { - name = "before_workday"; - platform = "workday"; - country = "DE"; - province = "NW"; - workdays = [ "mon" "tue" "wed" "thu" "fri" ]; - days_offset = 1; - } - { - name = "workday"; - platform = "workday"; - country = "DE"; - province = "NW"; - workdays = [ "mon" "tue" "wed" "thu" "fri" ]; - } - ]; - }; services.home-assistant = { diff --git a/configs/pepe/home-assistant/dayOfWeek.nix b/configs/pepe/home-assistant/dayOfWeek.nix deleted file mode 100644 index 0aba0d1..0000000 --- a/configs/pepe/home-assistant/dayOfWeek.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ config, ... }: -let - - folderPath = config.services.home-assistant.configDir; - filePath = "${folderPath}/dayOfWeek.json"; - -in { - services.homeAssistantConfig = { - - sensor = [{ - platform = "file"; - name = "day_of_week"; - file_path = filePath; - value_template = "{{ value_json.dayOfWeek }}"; - }]; - - homeassistant = { - whitelist_external_dirs = [ folderPath ]; - customize."sensor.day_of_week" = { - icon = "mdi:calendar-today"; - friendly_name = "Wochen Tag"; - }; - }; - - group = { overview.entities = [ "sensor.day_of_week" ]; }; - - }; - - systemd.services.dayOfWeek = { - enable = true; - before = [ "home-assistant.service" ]; - wantedBy = [ "home-assistant.service" ]; - serviceConfig = { - User = "hass"; - Type = "oneshot"; - }; - description = "set day of wek for homeassistant"; - script = # sh - '' - date +'{"dayOfWeek":"%A"}' >> ${filePath} - ''; - }; - systemd.timers.dayOfWeek = { - enable = true; - wantedBy = [ "multi-user.target" ]; - timerConfig = { - OnCalendar = "00:01:00"; - Persistent = "true"; - }; - }; - -} diff --git a/configs/pepe/home-assistant/holiday.nix b/configs/pepe/home-assistant/holiday.nix deleted file mode 100644 index fea17a4..0000000 --- a/configs/pepe/home-assistant/holiday.nix +++ /dev/null @@ -1,92 +0,0 @@ -{ config, pkgs, ... }: -let - - state = "NW"; # NRW - # state = "BE"; # Berlin - - name = "holiday"; - folderPath = config.services.home-assistant.configDir; - filePath = "${folderPath}/${name}.json"; - -in { - services.homeAssistantConfig = { - - # todo : use the python tool - sensor = [ - { - platform = "file"; - name = "${name}_date"; - file_path = filePath; - value_template = "{{ value_json.date }}"; - } - { - platform = "file"; - name = "${name}_name"; - file_path = filePath; - value_template = "{{ value_json.name }}"; - } - ]; - - homeassistant = { - whitelist_external_dirs = [ folderPath ]; - customize = { - "sensor.${name}_date" = { - icon = "mdi:calendar"; - friendly_name = "Nächster Feiertag"; - }; - "sensor.${name}_name" = { - icon = "mdi:calendar"; - friendly_name = "Nächster Feiertag"; - }; - }; - }; - - group = { - - holidays = { - name = "Feiertage"; - view = false; - control = "hidden"; - entities = [ "sensor.${name}_date" "sensor.${name}_name" ]; - }; - - view_overview.entities = [ "group.holidays" ]; - - }; - - }; - - systemd.services."${name}" = { - enable = true; - before = [ "home-assistant.service" ]; - wantedBy = [ "home-assistant.service" ]; - serviceConfig = { - User = "hass"; - Type = "oneshot"; - }; - description = "set ${name} for homeassistant"; - script = # sh - '' - ${pkgs.curl}/bin/curl \ - -Ls "https://feiertage-api.de/api/?jahr=$( date +%Y )&nur_land=${state}" \ - | ${pkgs.jq}/bin/jq --compact-output ' - map_values( .datum ) | - to_entries | - map( { date: .value, name : .key } ) | - sort_by( .date ) | - map(select ( .date >= "'`date +%Y-%m-%d`'" )) | - .[0]' \ - >> ${filePath} - ''; - }; - - systemd.timers."${name}" = { - enable = true; - wantedBy = [ "multi-user.target" ]; - timerConfig = { - OnCalendar = "daily"; - Persistent = "true"; - }; - }; - -} diff --git a/configs/pepe/home-assistant/weather.nix b/configs/pepe/home-assistant/weather.nix new file mode 100644 index 0000000..40bfc5a --- /dev/null +++ b/configs/pepe/home-assistant/weather.nix @@ -0,0 +1,16 @@ +{ config, ... }: { + services.homeAssistantConfig = { + + sensor = [ + # Weather prediction + { + platform = "zamg"; + name = "weather"; + } + ]; + + group = { overview.entities = [ "sensor.weather" ]; }; + + }; + +} diff --git a/configs/pepe/home-assistant/workday.nix b/configs/pepe/home-assistant/workday.nix new file mode 100644 index 0000000..18e1bc9 --- /dev/null +++ b/configs/pepe/home-assistant/workday.nix @@ -0,0 +1,45 @@ +{ config, ... }: { + services.homeAssistantConfig = { + + # todo: add holidays package to home-assiatnt + binary_sensor = [ + { + name = "before_workday"; + platform = "workday"; + country = "DE"; + province = "NW"; + workdays = [ "mon" "tue" "wed" "thu" "fri" ]; + days_offset = 1; + } + { + name = "workday"; + platform = "workday"; + country = "DE"; + province = "NW"; + workdays = [ "mon" "tue" "wed" "thu" "fri" ]; + } + ]; + + homeassistant.customize = { + "binary_sensor.workday" = { + icon = "mdi:calendar"; + friendly_name = "Today?"; + }; + "binary_sensor.before_workday" = { + icon = "mdi:calendar"; + friendly_name = "Tomorrow?"; + }; + }; + + group = { + is_workday = { + name = "Workday"; + control = "hidden"; + entities = [ "binary_sensor.before_workday" "binary_sensor.workday" ]; + }; + view_overview.entities = [ "group.is_workday" ]; + }; + + }; + +} diff --git a/system/all/tinc.nix b/system/all/tinc.nix index 7ea4dea..6c19d27 100644 --- a/system/all/tinc.nix +++ b/system/all/tinc.nix @@ -110,7 +110,8 @@ in { }; sputnik = { realAddress = [ - # "195.201.134.247:443" + "195.201.134.247" + "195.201.134.247:443" "static.247.134.201.195.clients.your-server.de" "static.247.134.201.195.clients.your-server.de:443" ];