From a7af1c3b9346f68c53208ab7df726751828f8434 Mon Sep 17 00:00:00 2001 From: darthsandmann Date: Fri, 29 Jul 2022 03:05:27 +0200 Subject: [PATCH] First Commit --- README.md | 22 + configuration.yaml | 6 + lovelace/batteries.yaml | 24 + lovelace/climate.yaml | 47 ++ lovelace/energy.yaml | 31 ++ lovelace/lights.yaml | 29 ++ lovelace/nas.yaml | 24 + lovelace/welcome.yaml | 40 ++ packages/climate/eq3.yaml.disabled | 587 ++++++++++++++++++++++ packages/darksky.yaml | 22 + packages/homeassistant/default_theme.yaml | 12 + packages/homeassistant/homeassistant.yaml | 13 + packages/homeassistant/lovelace.yaml | 22 + packages/homeassistant/recorder.yaml | 7 + packages/light/circadian.yaml | 16 + packages/light/lightscenes.yaml | 25 + packages/light/lightstore.yaml | 28 ++ packages/light/yeelight.yaml | 83 +++ packages/minimalist/custom_entities.yaml | 3 + packages/nas/wol.yaml | 29 ++ python_scripts/light_store.py | 119 +++++ ui-lovelace.yaml | 37 ++ 22 files changed, 1226 insertions(+) create mode 100644 README.md create mode 100644 configuration.yaml create mode 100644 lovelace/batteries.yaml create mode 100644 lovelace/climate.yaml create mode 100644 lovelace/energy.yaml create mode 100644 lovelace/lights.yaml create mode 100644 lovelace/nas.yaml create mode 100644 lovelace/welcome.yaml create mode 100644 packages/climate/eq3.yaml.disabled create mode 100644 packages/darksky.yaml create mode 100644 packages/homeassistant/default_theme.yaml create mode 100644 packages/homeassistant/homeassistant.yaml create mode 100644 packages/homeassistant/lovelace.yaml create mode 100644 packages/homeassistant/recorder.yaml create mode 100644 packages/light/circadian.yaml create mode 100644 packages/light/lightscenes.yaml create mode 100644 packages/light/lightstore.yaml create mode 100644 packages/light/yeelight.yaml create mode 100644 packages/minimalist/custom_entities.yaml create mode 100644 packages/nas/wol.yaml create mode 100644 python_scripts/light_store.py create mode 100644 ui-lovelace.yaml diff --git a/README.md b/README.md new file mode 100644 index 0000000..5aaac75 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Homeassistant Config + +## Hacs + +### Integrations + +- Circadian Lighting +- browser_mod +- UI Lovelace Minimalist + + +### Frontend + +- button-card +- Mini Media Player +- Simple Weather Card +- Light Entity Card +- auto-entities +- card-mod +- Sun Card +- mini-graph-card +- My Cards Bundle (https://github.com/AnthonMS/my-cards) \ No newline at end of file diff --git a/configuration.yaml b/configuration.yaml new file mode 100644 index 0000000..af98fd2 --- /dev/null +++ b/configuration.yaml @@ -0,0 +1,6 @@ +homeassistant: + packages: !include_dir_named packages + + +frontend: + themes: !include_dir_merge_named themes \ No newline at end of file diff --git a/lovelace/batteries.yaml b/lovelace/batteries.yaml new file mode 100644 index 0000000..1b403d6 --- /dev/null +++ b/lovelace/batteries.yaml @@ -0,0 +1,24 @@ +- type: 'custom:button-card' + template: card_title + name: Batteries + + +- type: "horizontal-stack" + cards: + - type: 'custom:button-card' + template: card_battery + entity: sensor.iphone_battery_level + variables: + ulm_card_battery_charger_type_entity_id: sensor.iphone_battery_level + ulm_card_battery_battery_level_danger: 30 + ulm_card_battery_battery_level_warning: 80 + ulm_card_battery_name: iPhone + + - type: 'custom:button-card' + template: card_battery + entity: sensor.ipad_battery_level + variables: + ulm_card_battery_charger_type_entity_id: sensor.ipad_battery_level + ulm_card_battery_battery_level_danger: 30 + ulm_card_battery_battery_level_warning: 80 + ulm_card_battery_name: iPad \ No newline at end of file diff --git a/lovelace/climate.yaml b/lovelace/climate.yaml new file mode 100644 index 0000000..fc87aca --- /dev/null +++ b/lovelace/climate.yaml @@ -0,0 +1,47 @@ +- type: 'custom:button-card' + template: card_title + name: Climate + + +- type: custom:button-card + template: custom_card_httpedo13_sun + + +- type: "custom:button-card" + template: card_weather + entity: weather.dark_sky + variables: + ulm_card_weather_name: " " + ulm_card_weather_primary_info: + - wind_speed + - precipitation_probability + ulm_card_weather_backdrop: + fade: true + + +- type: 'custom:button-card' + template: card_graph + entity: sensor.temperature_kai_temperature + variables: + ulm_card_graph_color: "var(--google-blue)" + ulm_card_graph_name: Temperature + ulm_card_graph_entity: sensor.temperature_kai_temperature + ulm_card_graph_color2: "var(--google-green)" + ulm_card_graph_entity2: sensor.temperature_outside_darksky + ulm_card_graph_type: fill + ulm_card_graph_hours: 6 + + +- type: "horizontal-stack" + cards: + - type: 'custom:button-card' + template: card_generic + entity: sensor.temperature_kai_humidity + variables: + ulm_card_generic_name: Humidity + + - type: 'custom:button-card' + template: card_generic + entity: sensor.temperature_kai_pressure + variables: + ulm_card_generic_name: Pressure \ No newline at end of file diff --git a/lovelace/energy.yaml b/lovelace/energy.yaml new file mode 100644 index 0000000..8629107 --- /dev/null +++ b/lovelace/energy.yaml @@ -0,0 +1,31 @@ +- type: 'custom:button-card' + template: card_title + name: Energy + + +- type: 'custom:button-card' + template: card_graph + entity: sensor.schreibtisch_current_consumption + variables: + ulm_card_graph_color: "var(--google-green)" + ulm_card_graph_name: Desk + ulm_card_graph_entity: sensor.schreibtisch_current_consumption + ulm_card_graph_type: fill + ulm_card_graph_hours: 12 + + +- type: "horizontal-stack" + cards: + - type: 'custom:button-card' + template: card_generic + entity: sensor.schreibtisch_today_s_consumption + variables: + ulm_card_generic_name: Today + ulm_card_generic_icon: "mdi:home-lightning-bolt" + + - type: 'custom:button-card' + template: card_generic + entity: sensor.schreibtisch_total_consumption + variables: + ulm_card_generic_name: Total + ulm_card_generic_icon: "mdi:home-lightning-bolt" \ No newline at end of file diff --git a/lovelace/lights.yaml b/lovelace/lights.yaml new file mode 100644 index 0000000..56f513d --- /dev/null +++ b/lovelace/lights.yaml @@ -0,0 +1,29 @@ +- type: 'custom:button-card' + template: card_title + name: Lights + + +- type: "horizontal-stack" + cards: + - type: 'custom:button-card' + template: card_light_slider_collapse + variables: + ulm_card_light_slider_collapse_name: Indirect + ulm_card_light_enable_collapse: false + ulm_card_light_name: Indirect + entity: light.all_indirect + + - type: 'custom:button-card' + template: card_light_slider_collapse + variables: + ulm_card_light_slider_collapse_name: Direct + ulm_card_light_enable_collapse: false + ulm_card_light_name: Direct + entity: light.all_direct + + +- type: 'custom:button-card' + template: card_input_boolean + entity: switch.circadian_lighting_circadian_lighting + variables: + ulm_card_input_boolean_name: Circadian Lighting \ No newline at end of file diff --git a/lovelace/nas.yaml b/lovelace/nas.yaml new file mode 100644 index 0000000..87e3295 --- /dev/null +++ b/lovelace/nas.yaml @@ -0,0 +1,24 @@ +- type: 'custom:button-card' + template: card_title + name: NAS + + +- type: "horizontal-stack" + cards: + - type: 'custom:button-card' + template: card_script + variables: + ulm_card_script_title: WOL + ulm_card_script_icon: 'mdi:power' + tap_action: + action: call-service + service: switch.turn_on + service_data: + entity_id: switch.server + + - type: 'custom:button-card' + template: card_binary_sensor + variables: + ulm_card_binary_sensor_alert: true + ulm_show_last_changed: true + entity: switch.server_template \ No newline at end of file diff --git a/lovelace/welcome.yaml b/lovelace/welcome.yaml new file mode 100644 index 0000000..84b71a5 --- /dev/null +++ b/lovelace/welcome.yaml @@ -0,0 +1,40 @@ +- type: 'custom:button-card' + template: card_title + name: Home Assistant +- type: "custom:button-card" + template: "card_welcome_scenes" + triggers_update: input_boolean.welcome_collapse + entity: input_boolean.welcome_collapse + variables: + ulm_card_welcome_scenes_collapse: input_boolean.welcome_collapse + ulm_weather: "weather.dark_sky" + entity_1: + entity_id: scene.light_flux + icon: "mdi:theme-light-dark" + icon_color: "yellow" + name: "Flux" + bg_color: "yellow" + entity_2: + entity_id: scene.light_blue + icon: "mdi:television-play" + icon_color: "blue" + name: "Blue" + bg_color: "blue" + entity_3: + entity_id: "scene.light_night" + icon: "mdi:weather-night" + icon_color: "purple" + name: "Night" + bg_color: "purple" + entity_4: + entity_id: "script.light_store_restore" + icon: "mdi:lightbulb-group" + icon_color: "green" + name: "All On" + bg_color: "green" + entity_5: + entity_id: "scene.light_alloff" + icon: "mdi:lightbulb-group-off-outline" + icon_color: "red" + name: "All Off" + bg_color: "red" \ No newline at end of file diff --git a/packages/climate/eq3.yaml.disabled b/packages/climate/eq3.yaml.disabled new file mode 100644 index 0000000..f685acf --- /dev/null +++ b/packages/climate/eq3.yaml.disabled @@ -0,0 +1,587 @@ +## -------------------------------------------------------------------------------------------------## +## EQ3-Heizthermostat +## -------------------------------------------------------------------------------------------------## +climate: + - platform: eq3btsmart + devices: + kai: + mac: '00:1A:22:0E:FB:32' + + +## -------------------------------------------------------------------------------------------------## +## Scripts: um einzelne Temperaturen zu setzen da Variable Fehler ausgibt (BUG) +## Ugly but working.... +## -------------------------------------------------------------------------------------------------## +script: + climate_set_15_0: + sequence: + - service: climate.turn_off + entity_id: climate.kai + climate_set_15_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "15.50" + hvac_mode: "heat" + climate_set_16_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "16.00" + hvac_mode: "heat" + climate_set_16_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "16.50" + hvac_mode: "heat" + climate_set_17_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "17.00" + hvac_mode: "heat" + climate_set_17_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "17.50" + hvac_mode: "heat" + climate_set_18_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "18.00" + hvac_mode: "heat" + climate_set_18_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "18.50" + hvac_mode: "heat" + climate_set_19_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "19.00" + hvac_mode: "heat" + climate_set_19_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "19.50" + hvac_mode: "heat" + climate_set_20_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "20.00" + hvac_mode: "heat" + climate_set_20_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "20.00" + hvac_mode: "heat" + climate_set_21_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "21.00" + hvac_mode: "heat" + climate_set_21_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "21.50" + hvac_mode: "heat" + climate_set_22_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "22.00" + hvac_mode: "heat" + climate_set_22_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "22.50" + hvac_mode: "heat" + climate_set_23_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "23.00" + hvac_mode: "heat" + climate_set_23_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "23.50" + hvac_mode: "heat" + climate_set_24_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "24.00" + hvac_mode: "heat" + climate_set_24_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "24.50" + hvac_mode: "heat" + climate_set_25_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "25.00" + hvac_mode: "heat" + climate_set_25_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "25.50" + hvac_mode: "heat" + climate_set_26_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "26.00" + hvac_mode: "heat" + climate_set_26_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "26.50" + hvac_mode: "heat" + climate_set_27_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "27.00" + hvac_mode: "heat" + climate_set_27_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "27.50" + hvac_mode: "heat" + climate_set_28_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "28.00" + hvac_mode: "heat" + climate_set_28_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "28.50" + hvac_mode: "heat" + climate_set_29_0: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "29.00" + hvac_mode: "heat" + climate_set_29_5: + sequence: + - service: climate.set_temperature + entity_id: climate.kai + data: + temperature: "29.50" + hvac_mode: "heat" + climate_set_off: + sequence: + - service: climate.turn_off + entity_id: climate.kai + climate_set: + alias: Setze Temperatur + sequence: + - service: script.turn_on + data_template: + entity_id: > + {% set temp_set = ( states("sensor.climate_temp_set") | float ) %} + {% if states("input_boolean.climate_power") == "off" %} script.climate_set_off + {% elif temp_set == ( "00.00" | float ) %} script.climate_set_20_5 + {% elif temp_set <= ( "15.00" | float ) %} script.climate_set_15_0 + {% elif temp_set == ( "15.50" | float ) %} script.climate_set_15_5 + {% elif temp_set == ( "16.00" | float ) %} script.climate_set_16_0 + {% elif temp_set == ( "16.50" | float ) %} script.climate_set_16_5 + {% elif temp_set == ( "17.00" | float ) %} script.climate_set_17_0 + {% elif temp_set == ( "17.50" | float ) %} script.climate_set_17_5 + {% elif temp_set == ( "18.00" | float ) %} script.climate_set_18_0 + {% elif temp_set == ( "18.50" | float ) %} script.climate_set_18_5 + {% elif temp_set == ( "19.00" | float ) %} script.climate_set_19_0 + {% elif temp_set == ( "19.50" | float ) %} script.climate_set_19_5 + {% elif temp_set == ( "20.00" | float ) %} script.climate_set_20_0 + {% elif temp_set == ( "20.50" | float ) %} script.climate_set_20_5 + {% elif temp_set == ( "21.00" | float ) %} script.climate_set_21_0 + {% elif temp_set == ( "21.50" | float ) %} script.climate_set_21_5 + {% elif temp_set == ( "22.00" | float ) %} script.climate_set_22_0 + {% elif temp_set == ( "22.50" | float ) %} script.climate_set_22_5 + {% elif temp_set == ( "23.00" | float ) %} script.climate_set_23_0 + {% elif temp_set == ( "23.50" | float ) %} script.climate_set_23_5 + {% elif temp_set == ( "24.00" | float ) %} script.climate_set_24_0 + {% elif temp_set == ( "24.50" | float ) %} script.climate_set_24_5 + {% elif temp_set == ( "25.00" | float ) %} script.climate_set_25_0 + {% elif temp_set == ( "25.50" | float ) %} script.climate_set_25_5 + {% elif temp_set == ( "26.00" | float ) %} script.climate_set_26_0 + {% elif temp_set == ( "26.50" | float ) %} script.climate_set_26_5 + {% elif temp_set == ( "27.00" | float ) %} script.climate_set_27_0 + {% elif temp_set == ( "27.50" | float ) %} script.climate_set_27_5 + {% elif temp_set == ( "28.00" | float ) %} script.climate_set_28_0 + {% elif temp_set == ( "28.50" | float ) %} script.climate_set_28_5 + {% elif temp_set == ( "29.00" | float ) %} script.climate_set_29_0 + {% elif temp_set >= ( "29.50" | float ) %} script.climate_set_29_5 + {% else %} script.climate_set_20_5 {% endif %} + + +## -------------------------------------------------------------------------------------------------## +## Inputs +## -------------------------------------------------------------------------------------------------## +input_number: + climate_temp: + name: Ziel Manuell + #initial: 21.5 + min: 15 + max: 29 + step: 0.5 + climate_temp_morning: + name: Ziel Morgen + #initial: 20.5 + min: 15 + max: 29 + step: 0.5 + climate_temp_night: + name: Ziel Nacht + #initial: 17.0 + min: 15 + max: 29 + step: 0.5 + climate_temp_accuracy: + name: Genauigkeit + #initial: 1 + min: 0 + max: 5 + step: 0.5 + climate_temp_offset: + name: Offset Heizung->Temp + #initial: 1 + min: -2 + max: 2 + step: 0.5 + climate_temp_last: + name: Letzte Temp + min: 0 + max: 29 + step: 0.01 + mode: box + +input_datetime: + climate_morning: + name: "Morgen" + has_time: true + has_date: false + #initial: "10:00" + climate_morning_weekend: + name: "Morgen Sa" + has_time: true + has_date: false + #initial: "15:30" + climate_night: + name: "Nacht" + has_time: true + has_date: false + #initial: "23:59" + +input_boolean: + climate_auto: + name: 'Automatisch' + icon: mdi:power + #initial: off + climate_power: + name: 'Power' + icon: mdi:power + #initial: off + climate_weekday: + name: 'Wochentag' + #initial: on + climate_away: + name: 'Away' + #initial: off + + +## -------------------------------------------------------------------------------------------------## +## Sensoren +## -------------------------------------------------------------------------------------------------## +sensor: + ## -----------------------------------------------------------------------------------------------## + ## Berechnung der Temperaturveränderung + ## -----------------------------------------------------------------------------------------------## + - platform: template + sensors: + climate_temp_change: + friendly_name: Veränderung + value_template: > + {% set now = states("sensor.aqara_temperature_kai_temperature")|float %} + {% set last = states("input_number.climate_temp_last")|float %} + {% set change = (now | float - last) | float %} + {% if now == ("0.0"|float) %} {% set change = ("0.0"|float) %} {% endif %} + {{ change | round(2) }} + ## -----------------------------------------------------------------------------------------------## + ## Berechnung der aktuellen Zieltemperatur bzgl Morgen/Nacht, Automatik/Manuell + ## -----------------------------------------------------------------------------------------------## + - platform: template + sensors: + climate_temp: + friendly_name: akt. Ziel + unit_of_measurement: '°C' + value_template: > + {% set auto = states("input_boolean.climate_auto") %} + {% set manual_temp = states("input_number.climate_temp") %} + {% if auto == "off" %} {{ manual_temp }} + {% else %} + {% set time = states("sensor.time") %} + {% set morning = states("sensor.climate_morning") %} + {% set weekday = states("input_boolean.climate_weekday") %} + {% if weekday == "on" %} {% set morning = states("input_datetime.climate_morning") %} + {% else %} {% set morning = states("input_datetime.climate_morning_weekend") %} {% endif %} + {% set night = states("input_datetime.climate_night") %} + {% set morning_temp = states("input_number.climate_temp_morning")|float %} + {% set night_temp = states("input_number.climate_temp_night")|float %} + {% if night > morning %} + {% if time > morning and time <= night %} {{ morning_temp|float }} + {% else %} {{ night_temp|float }} {% endif %} + {% else %} + {% if time <= morning and time > night %} {{ morning_temp|float }} + {% else %} {{ night_temp|float }} {% endif %} + {% endif %} + {% endif %} + ## -----------------------------------------------------------------------------------------------## + ## Berechnung von Unterschied zwischen Heizungstemperatur und realer Temperatur + ## -----------------------------------------------------------------------------------------------## + - platform: template + sensors: + climate_temp_difference: + friendly_name: 'akt. Unterschied' + value_template: > + {% if states("sensor.aqara_temperature_kai_temperature") == "unknown" %} + {{ 0 | float }} + {% else %} + {{ ( states("sensor.aqara_temperature_kai_temperature") | float - (states.sensor.climate_temp.state | float) ) | round(2) }} + {% endif %} + unit_of_measurement: '°C' + ## -----------------------------------------------------------------------------------------------## + ## Schrittgröße, mit der die Heizung verstellt werden soll, abhängig vom Unterschied zur realen + ## Temperatur + ## Variable Schrittgröße, bei positiv (zu warm) größer, bei negativ (zu kalt) geringer + ## -----------------------------------------------------------------------------------------------## + - platform: template + sensors: + climate_temp_steps: + friendly_name: 'Schrittgröße' + value_template: > + {% set difference = (states("sensor.climate_temp_difference" ) | float) %} + {% set zero = ("0.0" | float ) %} + {% if difference > zero %} + {% if difference >= ("2.00"|float) %} {% set steps = ( "3.00" | float ) %} + {% elif difference >= ("1.50"|float) %} {% set steps = ( "1.50" | float ) %} + {% elif difference >= ("1.00"|float) %} {% set steps = ( "1.00" | float ) %} + {% elif difference >= ("0.50"|float) %} {% set steps = ( "0.50" | float ) %} + {% elif difference >= ("0.00"|float) %} {% set steps = ( "0.00" | float ) %} + {% endif %} + {% else %} + {% if difference <= ("-2.00"|float) %} {% set steps = ( "3.00" | float ) %} + {% elif difference <= ("-1.50"|float) %} {% set steps = ( "1.50" | float ) %} + {% elif difference <= ("-1.00"|float) %} {% set steps = ( "0.50" | float ) %} + {% elif difference <= ("-0.50"|float) %} {% set steps = ( "0.50" | float ) %} + {% elif difference <= ("-0.00"|float) %} {% set steps = ( "0.00" | float ) %} + {% endif %} + {% endif %} + {{ steps }} + ## -----------------------------------------------------------------------------------------------## + ## Berechnung der Temperatur, auf die die Heizung gestellt werden soll, um Zieltemperatur zu + ## erreichen. Berücksichtigung für Genauigkeit, variable Temperaturanpassung und Temperatur- + ## anpassung aufgrund von Offset. Berechnung ob Anpassung Positiv oder Negativ + ## -----------------------------------------------------------------------------------------------## + - platform: template + sensors: + climate_temp_set: + friendly_name: '-> Heizung' + value_template: > + {% set difference = (states("sensor.climate_temp_difference" ) | float) %} + {% set change = (states("sensor.climate_temp_change" ) | float) %} + {% set goal = (states("sensor.climate_temp" ) | float) %} + {% set temp = (states("sensor.aqara_temperature_kai_temperature") | float ) %} + {% set climate = (state_attr("climate.kai", "temperature") | float ) %} + {% if climate < ("15.0" | float ) %} {% set climate = ("15.0" | float) %} {% endif %} + {% set max = states("sensor.climate_temp") | float %} + {% set min = states("sensor.climate_temp") | float - (states.input_number.climate_temp_accuracy.state | float) %} + {% set zero = ("0.0" | float ) %} + {% set difference_max = ("1.5" | float ) %} + {% set difference_min = ("-2.0" | float ) %} + {% set change_max = ("1.0" | float ) %} + {% set offset = (states("input_number.climate_temp_offset") | float ) %} + {% set climate_goal = (goal | float + ("2.0" | float) | float - offset) | float %} + {% set steps = (states("sensor.climate_temp_steps") | float) %} + {% if difference == zero %} {% set result = climate %} + {% elif (difference > difference_max) %} {% set result = ("15.0"|float) %} + {% elif (difference < difference_min) %} {% set result = goal - offset %} + {% elif difference > zero %} + {% if (climate_goal <= climate) or (change >= change_max) %} {% set result = goal - offset %} + {% elif temp > max %} {% set result = (climate | float - steps) | float %} + {% else %} {% set result = climate %} {% endif %} + {% elif difference < zero %} + {% if temp < min %} + {% set result = (climate | float + steps) | float %} + {% else %} + {% if change >= change_max %} + {% set result = goal - offset %} + {% else %} + {% set result = climate %} + {% endif %} + {% endif %} + {% endif %} + {% if result < ("15.0"|float) %} {{ ("15.0"|float) }} + {% elif result > ("29.5"|float) %} {{ ("29.5"|float) }} + {% else %} {{ result }} + {% endif %} + unit_of_measurement: '°C' + ## -----------------------------------------------------------------------------------------------## + ## Time / Date + ## -----------------------------------------------------------------------------------------------## + - platform: time_date + display_options: + - 'time' + - 'date' + + +automation: + ## -----------------------------------------------------------------------------------------------## + ## Trigger alle 15min um Abfrage und Temperaturanpassung durchzuführen + ## -----------------------------------------------------------------------------------------------## + - alias: climate_set_auto + initial_state: on + trigger: + - platform: time_pattern + minutes: '/5' + - platform: state + entity_id: sensor.climate_temp + condition: + - condition: template + value_template: '{{ states.climate.kai.state != "unavailable" }}' + action: + - service: script.turn_on + entity_id: script.climate_set + - delay: '00:20' + - service: script.turn_on + entity_id: script.climate_set + - service: input_number.set_value + data_template: + entity_id: input_number.climate_temp_last + value: '{{ states("sensor.aqara_temperature_kai_temperature")|float }}' + - alias: climate_set_manual + initial_state: on + trigger: + - platform: state + entity_id: input_number.climate_temp + condition: + - condition: template + value_template: '{{ states.climate.kai.state != "unavailable" }}' + action: + - service: input_boolean.turn_off + entity_id: input_boolean.climate_auto + - service: script.turn_on + entity_id: script.climate_set + - delay: '00:20' + - service: script.turn_on + entity_id: script.climate_set + - alias: climate_set_power_off + initial_state: on + trigger: + - platform: state + entity_id: input_boolean.climate_power + to: "off" + action: + - service: climate.turn_off + entity_id: climate.kai + - delay: '00:20' + - service: climate.turn_off + entity_id: climate.kai + - alias: climate_set_power_on + initial_state: on + trigger: + - platform: state + entity_id: input_boolean.climate_power + to: "on" + action: + - service: climate.turn_on + entity_id: climate.kai + - delay: '00:20' + - service: climate.turn_on + entity_id: climate.kai + ## -----------------------------------------------------------------------------------------------## + ## Trigger alle 5min, wenn Wochentag -> aktiviere Weekday-Boolean + ## -----------------------------------------------------------------------------------------------## + - alias: climate_weekday + initial_state: on + trigger: + platform: time_pattern + minutes: '/5' + condition: + - condition: time + weekday: + - mon + - tue + - wed + - thu + - fri + - sun + action: + service: input_boolean.turn_on + entity_id: input_boolean.climate_weekday + ## -----------------------------------------------------------------------------------------------## + ## Trigger alle 5min, wenn Wochenende -> deaktiviere Weekday-Boolean + ## -----------------------------------------------------------------------------------------------## + - alias: climate_weekend + initial_state: on + trigger: + platform: time_pattern + minutes: '/5' + condition: + - condition: time + weekday: + - sat + action: + service: input_boolean.turn_off + entity_id: input_boolean.climate_weekday \ No newline at end of file diff --git a/packages/darksky.yaml b/packages/darksky.yaml new file mode 100644 index 0000000..400de81 --- /dev/null +++ b/packages/darksky.yaml @@ -0,0 +1,22 @@ +## -------------------------------------------------------------------------------------------------## +## DarkSky +## -------------------------------------------------------------------------------------------------## + + +## -------------------------------------------------------------------------------------------------## +## Wetter-Plattform +## -------------------------------------------------------------------------------------------------## +weather: + - platform: darksky + api_key: !secret darksky + mode: daily + +sun: + + +sensor: + - platform: template + sensors: + temperature_outside_darksky: + value_template: '{{ states.weather.dark_sky.attributes.temperature }}' + friendly_name: 'Outside Temperature' \ No newline at end of file diff --git a/packages/homeassistant/default_theme.yaml b/packages/homeassistant/default_theme.yaml new file mode 100644 index 0000000..844433e --- /dev/null +++ b/packages/homeassistant/default_theme.yaml @@ -0,0 +1,12 @@ +automation: + - id: 'default_theme' + alias: Set Theme on HA Start + description: '' + trigger: + - event: start + platform: homeassistant + condition: [] + action: + - data: + name: minimalist-desktop + service: frontend.set_theme \ No newline at end of file diff --git a/packages/homeassistant/homeassistant.yaml b/packages/homeassistant/homeassistant.yaml new file mode 100644 index 0000000..ba3c8b9 --- /dev/null +++ b/packages/homeassistant/homeassistant.yaml @@ -0,0 +1,13 @@ +homeassistant: + name: Home + latitude: !secret latitude + longitude: !secret longitude + elevation: !secret elevation + unit_system: metric + temperature_unit: C + time_zone: Europe/Berlin + allowlist_external_dirs: + - '/tmp' + + +default_config: \ No newline at end of file diff --git a/packages/homeassistant/lovelace.yaml b/packages/homeassistant/lovelace.yaml new file mode 100644 index 0000000..5805482 --- /dev/null +++ b/packages/homeassistant/lovelace.yaml @@ -0,0 +1,22 @@ +lovelace: + mode: yaml + + resources: + - url: /hacsfiles/button-card/button-card.js + type: module + - url: /hacsfiles/light-entity-card/light-entity-card.js + type: module + - url: /hacsfiles/lovelace-auto-entities/auto-entities.js + type: module + - url: /hacsfiles/lovelace-card-mod/card-mod.js + type: module + - url: /hacsfiles/mini-graph-card/mini-graph-card-bundle.js + type: module + - url: /hacsfiles/mini-media-player/mini-media-player-bundle.js + type: module + - url: /hacsfiles/my-cards/my-slider.js + type: module + - url: /hacsfiles/simple-weather-card/simple-weather-card-bundle.js + type: module + - url: /hacsfiles/home-assistant-sun-card/home-assistant-sun-card.js + type: module \ No newline at end of file diff --git a/packages/homeassistant/recorder.yaml b/packages/homeassistant/recorder.yaml new file mode 100644 index 0000000..d19f432 --- /dev/null +++ b/packages/homeassistant/recorder.yaml @@ -0,0 +1,7 @@ +recorder: + db_url: !secret db_url + auto_purge: true + purge_keep_days: 60 + exclude: + entities: + - sensor.time \ No newline at end of file diff --git a/packages/light/circadian.yaml b/packages/light/circadian.yaml new file mode 100644 index 0000000..2a1af2f --- /dev/null +++ b/packages/light/circadian.yaml @@ -0,0 +1,16 @@ +## -------------------------------------------------------------------------------------------------## +## Circadian Lighting / Flux +## -------------------------------------------------------------------------------------------------## +circadian_lighting: + min_colortemp: 2700 + max_colortemp: 6500 + interval: 450 + transition: 8 + + +switch: + - platform: circadian_lighting + lights_ct: + - light.stripe + - light.direct + max_brightness: 80 \ No newline at end of file diff --git a/packages/light/lightscenes.yaml b/packages/light/lightscenes.yaml new file mode 100644 index 0000000..4e59de2 --- /dev/null +++ b/packages/light/lightscenes.yaml @@ -0,0 +1,25 @@ +scene: + - name: light_alloff + entities: + light.all_lights: false + - name: light_flux + entities: + light.all_direct: false + light.all_indirect: true + switch.circadian_lighting_circadian_lighting: on + - name: light_blue + entities: + switch.circadian_lighting_circadian_lighting: off + light.all_direct: false + light.all_indirect: + rgb_color: [0, 0, 255] + state: true + brightness: 20 + - name: light_night + entities: + switch.circadian_lighting_circadian_lighting: off + light.all_direct: false + light.all_indirect: + rgb_color: [255, 139, 21] + state: true + brightness: 1 \ No newline at end of file diff --git a/packages/light/lightstore.yaml b/packages/light/lightstore.yaml new file mode 100644 index 0000000..8f7a7dc --- /dev/null +++ b/packages/light/lightstore.yaml @@ -0,0 +1,28 @@ +## -------------------------------------------------------------------------------------------------## +## Light_Store +## https://github.com/pnbruckner/homeassistant-config/blob/master/python_scripts/light_store.py +## -------------------------------------------------------------------------------------------------## +script: + light_store_save: + sequence: + - service: python_script.light_store + data: + store_name: flash_store + entity_id: + - light.bed + - light.closet + - light.desk + - light.direct + - light.tv + light_store_off: + sequence: + - service: script.light_store_save + - service: light.turn_off + entity_id: light.all_lights + light_store_restore: + sequence: + - service: python_script.light_store + data: + store_name: flash_store + operation: restore + diff --git a/packages/light/yeelight.yaml b/packages/light/yeelight.yaml new file mode 100644 index 0000000..02b7c01 --- /dev/null +++ b/packages/light/yeelight.yaml @@ -0,0 +1,83 @@ +## -------------------------------------------------------------------------------------------------## +## Yeelight +## -------------------------------------------------------------------------------------------------## + + +## -------------------------------------------------------------------------------------------------## +## Discovery disable +## -------------------------------------------------------------------------------------------------## +discovery: + ignore: + - yeelight + + +## -------------------------------------------------------------------------------------------------## +## Lampen-Konfig +## -------------------------------------------------------------------------------------------------## +yeelight: + devices: + 10.10.10.82: + name: ceiling1 + save_on_change: False + transition: 2500 + 10.10.10.83: + name: ceiling2 + save_on_change: False + transition: 2500 + 10.10.10.80: + name: ceiling3 + save_on_change: False + transition: 2500 + 10.10.10.81: + name: bed_ceiling + save_on_change: False + transition: 2500 + 10.10.10.84: + name: bed + save_on_change: False + transition: 2500 + model: strip1 + 10.10.10.85: + name: desk + save_on_change: False + transition: 2500 + model: strip1 + + +## -------------------------------------------------------------------------------------------------## +## Lampengruppen +## -------------------------------------------------------------------------------------------------## +light: + - platform: group + name: ceiling + entities: + - light.ceiling1 + - light.ceiling2 + - light.ceiling3 + - platform: group + name: direct + entities: + - light.bed_ceiling + - light.ceiling1 + - light.ceiling2 + - light.ceiling3 + - platform: group + name: stripe + entities: + - light.bed + - light.desk + - platform: group + name: all_direct + entities: + - light.direct + - platform: group + name: all_indirect + entities: + - light.stripe + - platform: group + name: all_lights + entities: + - light.all_direct + - light.all_indirect + + diff --git a/packages/minimalist/custom_entities.yaml b/packages/minimalist/custom_entities.yaml new file mode 100644 index 0000000..75b321b --- /dev/null +++ b/packages/minimalist/custom_entities.yaml @@ -0,0 +1,3 @@ +input_boolean: + welcome_collapse: + name: welcome_collapse \ No newline at end of file diff --git a/packages/nas/wol.yaml b/packages/nas/wol.yaml new file mode 100644 index 0000000..b4c0609 --- /dev/null +++ b/packages/nas/wol.yaml @@ -0,0 +1,29 @@ +## -------------------------------------------------------------------------------------------------## +## NAS - Wake on Lan +## -------------------------------------------------------------------------------------------------## +wake_on_lan: + + +switch: + - platform: wake_on_lan + mac: 54:04:A6:BF:1E:43 + name: Server + host: ip.wnsrt.de +#switch: + - platform: template + switches: + server_template: + friendly_name: Server + value_template: "{{ is_state('device_tracker.nas', 'home') }}" + icon_template: mdi:desktop-tower + turn_on: + service: switch.turn_on + target: + entity_id: switch.server + turn_off: + + +device_tracker: + - platform: ping + hosts: + nas: 192.168.178.81 \ No newline at end of file diff --git a/python_scripts/light_store.py b/python_scripts/light_store.py new file mode 100644 index 0000000..1340bb2 --- /dev/null +++ b/python_scripts/light_store.py @@ -0,0 +1,119 @@ +VERSION = '1.2.0' + +DOMAIN = 'light_store' + +ATTR_OPERATION = 'operation' +ATTR_OP_SAVE = 'save' +ATTR_OP_RESTORE = 'restore' +ATTR_OVERWRITE = 'overwrite' + +ATTR_STORE_NAME = 'store_name' +ATTR_ENTITY_ID = 'entity_id' + +# Select light attributes to save/restore. +ATTR_BRIGHTNESS = "brightness" +ATTR_EFFECT = "effect" +ATTR_WHITE_VALUE = "white_value" +ATTR_COLOR_TEMP = "color_temp" +ATTR_HS_COLOR = "hs_color" +# Save any of these attributes. +GEN_ATTRS = [ATTR_BRIGHTNESS, ATTR_EFFECT] +# Save only one of these attributes, in order of precedence. +COLOR_ATTRS = [ATTR_WHITE_VALUE, ATTR_COLOR_TEMP, ATTR_HS_COLOR] + +def store_entity_id(store_name, entity_id): + return '{}.{}'.format(store_name, entity_id.replace('.', '_')) + +# Get operation (default to save.) +operation = data.get(ATTR_OPERATION, ATTR_OP_SAVE) +if operation not in [ATTR_OP_SAVE, ATTR_OP_RESTORE]: + logger.error('Invalid operation. Expected {} or {}, got: {}'.format( + ATTR_OP_SAVE, ATTR_OP_RESTORE, operation)) +else: + # Get optional store name (default to DOMAIN.) + store_name = data.get(ATTR_STORE_NAME, DOMAIN) + + # Get optional overwrite parameter (only applies to saving.) + overwrite = data.get(ATTR_OVERWRITE, True) + + # Get optional list (or comma separated string) of switches & lights to + # save/restore. + entity_id = data.get(ATTR_ENTITY_ID) + if isinstance(entity_id, str): + entity_id = [e.strip() for e in entity_id.split(',')] + + # Replace any group entities with their contents. + # Repeat until no groups left in list. + expanded_a_group = True + while entity_id and expanded_a_group: + expanded_a_group = False + for e in entity_id: + if e.startswith('group.'): + entity_id.remove(e) + g = hass.states.get(e) + if g and 'entity_id' in g.attributes: + entity_id.extend(g.attributes['entity_id']) + expanded_a_group = True + + # Get lists of switches and lights that actually exist, + # and list of entities that were previously saved. + entity_ids = (hass.states.entity_ids('switch') + + hass.states.entity_ids('light')) + saved = hass.states.entity_ids(store_name) + # When restoring, limit to existing entities that were saved. + if operation == ATTR_OP_RESTORE: + saved_entity_ids = [] + for e in entity_ids: + if store_entity_id(store_name, e) in saved: + saved_entity_ids.append(e) + entity_ids = saved_entity_ids + + # If a list of entities was specified, further limit to just those. + # Otherwise, save all existing switches and lights, or restore + # all existing switches and lights that were previously saved. + if entity_id: + entity_ids = tuple(set(entity_ids).intersection(set(entity_id))) + + if operation == ATTR_OP_SAVE: + # Only save if not already saved, or if overwite is True. + if not saved or overwrite: + # Clear out any previously saved states. + for entity_id in saved: + hass.states.remove(entity_id) + + # Save selected switches and lights to store. + for entity_id in entity_ids: + cur_state = hass.states.get(entity_id) + if cur_state is None: + logger.error('Could not get state of {}.'.format(entity_id)) + else: + attributes = {} + if entity_id.startswith('light.') and cur_state.state == 'on': + for attr in GEN_ATTRS: + if attr in cur_state.attributes: + attributes[attr] = cur_state.attributes[attr] + for attr in COLOR_ATTRS: + if attr in cur_state.attributes: + attributes[attr] = cur_state.attributes[attr] + break + hass.states.set(store_entity_id(store_name, entity_id), + cur_state.state, attributes) + else: + # Restore selected switches and lights from store. + for entity_id in entity_ids: + old_state = hass.states.get(store_entity_id(store_name, entity_id)) + if old_state is None: + logger.error('No saved state for {}.'.format(entity_id)) + else: + turn_on = old_state.state == 'on' + service_data = {'entity_id': entity_id} + component = entity_id.split('.')[0] + if component == 'light' and turn_on and old_state.attributes: + service_data.update(old_state.attributes) + hass.services.call(component, + 'turn_on' if turn_on else 'turn_off', + service_data) + + # Remove saved states now that we're done with them. + for entity_id in saved: + hass.states.remove(entity_id) \ No newline at end of file diff --git a/ui-lovelace.yaml b/ui-lovelace.yaml new file mode 100644 index 0000000..089828e --- /dev/null +++ b/ui-lovelace.yaml @@ -0,0 +1,37 @@ +--- +button_card_templates: !include_dir_merge_named "custom_components/ui_lovelace_minimalist/__ui_minimalist__/ulm_templates/" + + +title: "Overview" +theme: "minimalist-desktop" +background: "var(--background-image)" + + +views: + - title: "Overview" + path: 0 + cards: + + - type: "vertical-stack" + cards: + !include lovelace/welcome.yaml + + - type: "vertical-stack" + cards: + !include lovelace/lights.yaml + + - type: "vertical-stack" + cards: + !include lovelace/climate.yaml + + - type: "vertical-stack" + cards: + !include lovelace/batteries.yaml + + - type: "vertical-stack" + cards: + !include lovelace/energy.yaml + + - type: "vertical-stack" + cards: + !include lovelace/nas.yaml \ No newline at end of file