From 8f02e3b18e474cb8ebf7eb18ac2ed006cb30a8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Miotk?= Date: Thu, 12 Dec 2024 18:01:57 +0100 Subject: [PATCH] Add Tasmota OpenTherm to HA (#35) --- .../apps/home-assistant/defaults/main.yml | 36 ++-- .../files/config/configuration.yaml | 2 + .../files/config/dashboard-tesla.yaml | 55 ------ .../home-assistant/files/config/mqtt.yaml | 60 +++++++ .../home-assistant/files/config/template.yaml | 11 ++ .../apps/home-assistant/tasks/config.yml | 21 +++ .../config/automations/automations.yaml | 38 +++- .../templates/config/automations/piec.yaml | 99 ++++++++++ .../templates/config/climate.yaml | 6 +- .../config/mqtt/water_heater/opentherm.yaml | 75 ++++++++ .../config/sensors/saj.yaml} | 0 .../templates/config/switch.yaml | 8 +- .../templates/config/ui-lovelace.yaml | 170 ++++++++++++------ roles/servers/bootstrap/handlers/main.yml | 5 + roles/servers/bootstrap/tasks/main.yml | 5 + roles/servers/bootstrap/tasks/ssh_keys.yml | 30 +++- roles/servers/bootstrap/tasks/user.yml | 17 ++ 17 files changed, 503 insertions(+), 135 deletions(-) delete mode 100644 roles/servers/apps/home-assistant/files/config/dashboard-tesla.yaml create mode 100644 roles/servers/apps/home-assistant/templates/config/automations/piec.yaml create mode 100644 roles/servers/apps/home-assistant/templates/config/mqtt/water_heater/opentherm.yaml rename roles/servers/apps/home-assistant/{files/config/sensors.yaml => templates/config/sensors/saj.yaml} (100%) create mode 100644 roles/servers/bootstrap/handlers/main.yml diff --git a/roles/servers/apps/home-assistant/defaults/main.yml b/roles/servers/apps/home-assistant/defaults/main.yml index 75254db8..252f64b9 100644 --- a/roles/servers/apps/home-assistant/defaults/main.yml +++ b/roles/servers/apps/home-assistant/defaults/main.yml @@ -62,27 +62,33 @@ home_assistant: climate: # - name: garaz - name: przedpokoj - switch: switch.sonoff_4chpror3_podlogowkadol1_4chpror3_switch_przedpokoj - # - name: lazienka_dol - # switch: switch.sonoff_4chpror3_podlogowkadol1_4chpror3_switch_przedpokoj + switch: switch.sonoff_4chpror3_ogrzewanie_dol2_sonoff_4chpror3_ogrzewanie_dol2_korytarz + - name: lazienka_dol + switch: switch.sonoff_4chpror3_ogrzewanie_dol1_sonoff_4chpror3_ogrzewanie_dol1_lazienka - name: salon - switch: switch.sonoff_4chpror3_podlogowkadol1_4chpror3_switch_przedpokoj + switch: switch.sonoff_4chpror3_ogrzewanie_dol1_sonoff_4chpror3_ogrzewanie_dol1_salon - name: kuchnia - switch: switch.sonoff_4chpror3_podlogowkadol1_4chpror3_switch_przedpokoj + switch: switch.sonoff_4chpror3_ogrzewanie_dol1_sonoff_4chpror3_ogrzewanie_dol1_kuchnia - name: sypialnia_dol - switch: switch.sonoff_4chpror3_podlogowkadol1_4chpror3_switch_przedpokoj + switch: switch.sonoff_4chpror3_ogrzewanie_dol1_sonoff_4chpror3_ogrzewanie_dol1_sypialnia - name: pokoj_julia - switch: switch.sonoff_4chpror3_podlogowkagora1_4chpror3_switch_przedpokoj - - name: serwerownia - switch: switch.sonoff_4chpror3_podlogowkagora1_4chpror3_switch_przedpokoj - - name: pokoj_timi - switch: switch.sonoff_4chpror3_podlogowkagora1_4chpror3_switch_przedpokoj - - name: biuro_miki - switch: switch.sonoff_4chpror3_podlogowkagora1_4chpror3_switch_przedpokoj + switch: switch.sonoff_4chpror3_ogrzewanie_gora1_sonoff_4chpror3_ogrzewanie_gora1_pokoj_julia - name: sypialnia_gora - switch: switch.sonoff_4chpror3_podlogowkagora2_4chpror3_switch_przedpokoj + switch: switch.sonoff_4chpror3_ogrzewanie_gora1_sonoff_4chpror3_ogrzewanie_gora1_sypialnia - name: garderoba - switch: switch.sonoff_4chpror3_podlogowkagora2_4chpror3_switch_przedpokoj + switch: switch.sonoff_4chpror3_ogrzewanie_gora1_sonoff_4chpror3_ogrzewanie_gora1_garderoba + - name: biuro_miki + switch: switch.sonoff_4chpror3_ogrzewanie_gora1_sonoff_4chpror3_ogrzewanie_gora1_pokoj_nad_garazem + - name: lazienka_gora + switch: switch.sonoff_4chpror3_ogrzewanie_gora2_sonoff_4chpror3_ogrzewanie_gora2_lazienka + - name: pokoj_timi + switch: switch.group_ogrzewanie_pokoj_timi + + # - name: pokoj_timi + # switch: switch.sonoff_4chpror3_ogrzewanie_gora2_sonoff_4chpror3_ogrzewanie_gora2_pokoj_timi + # - name: serwerownia + # switch: switch.sonoff_4chpror3_ogrzewanie_gora2_sonoff_4chpror3_ogrzewanie_gora2_korytarz + mqtt: zigbee_coordinator_base_topic: "tasmota_10B490" diff --git a/roles/servers/apps/home-assistant/files/config/configuration.yaml b/roles/servers/apps/home-assistant/files/config/configuration.yaml index abbb3f4e..a5a3793f 100644 --- a/roles/servers/apps/home-assistant/files/config/configuration.yaml +++ b/roles/servers/apps/home-assistant/files/config/configuration.yaml @@ -72,6 +72,8 @@ virtual: switch: !include switch.yaml climate: !include climate.yaml +rest: + # scan_interval: 10 zha: zigpy_config: diff --git a/roles/servers/apps/home-assistant/files/config/dashboard-tesla.yaml b/roles/servers/apps/home-assistant/files/config/dashboard-tesla.yaml deleted file mode 100644 index d52fa739..00000000 --- a/roles/servers/apps/home-assistant/files/config/dashboard-tesla.yaml +++ /dev/null @@ -1,55 +0,0 @@ -views: - - title: Home - cards: - - show_name: true - show_icon: true - type: button - tap_action: - action: toggle - entity: switch.sonoff_4chpror3_dwor_4chpror3_switch_dwor_brama - name: Brama Dwor - icon: mdi:gate - - show_name: true - show_icon: true - type: button - tap_action: - action: toggle - entity: switch.sonoff_4chpror3_garaz_4chpror3_switch_garaz_brama - name: Brama Garazowa - icon: mdi:garage-variant - - show_name: true - show_icon: true - type: button - tap_action: - action: toggle - entity: switch.sonoff_4chpror3_garaz_4chpror3_swiatlo_garaz_wew - name: Garaz Swiatlo - icon: mdi:lightbulb-fluorescent-tube - - type: entities - entities: - - entity: binary_sensor.door_state_dwor_brama - name: Dwor Brama stan - icon: mdi:gate - - entity: binary_sensor.door_state_garaz_brama - name: Garaz Brama stan - icon: mdi:garage-variant - # - type: custom:frigate-card - # cameras: - # - camera_entity: camera.yi_garaz - # live_provider: webrtc-card - # - type: custom:frigate-card - # cameras: - # - camera_entity: camera.yi_kuchnia - # live_provider: webrtc-card - # - entity: sensor.th_temperature_ogrod - # type: custom:button-card - # name: Ogrod - # show_state: false - # secondary_info: last-changed - # entities: - # - entity: sensor.th_temperature_ogrod - # name: Temperatura - # - entity: sensor.th_humidity_ogrod - # name: Wilgotnosc - # - entity: sensor.th_battery_percentage_ogrod - # name: Bateria diff --git a/roles/servers/apps/home-assistant/files/config/mqtt.yaml b/roles/servers/apps/home-assistant/files/config/mqtt.yaml index 9c134bad..cc269771 100644 --- a/roles/servers/apps/home-assistant/files/config/mqtt.yaml +++ b/roles/servers/apps/home-assistant/files/config/mqtt.yaml @@ -6,3 +6,63 @@ binary_sensor: !include_dir_merge_list mqtt/binary_sensors/ light: !include_dir_merge_list mqtt/lights/ switch: !include_dir_merge_list mqtt/switches/ + +water_heater: + - name: "piec_ciepla_woda_uzytkowa" + temperature_command_topic: "cmnd/tasmota_1AA4E8/OT_TWATER" + temperature_state_topic: "tele/tasmota_1AA4E8/SENSOR" + temperature_state_template: "{{ value_json.OPENTHERM.DHWS }}" + current_temperature_topic: "tele/tasmota_1AA4E8/SENSOR" + current_temperature_template: "{{ value_json.OPENTHERM.TDHW }}" + modes: + - "off" + - "gas" + mode_command_topic: "cmnd/tasmota_1AA4E8/OT_CH" + mode_command_template: > + {% set values = { 'gas':'CH,DHW', 'off':'CH'} %} + {% set cmd = values[value] %} + {{ cmd }} + mode_state_topic: "tele/tasmota_1AA4E8/SENSOR" + mode_state_template: > + {% if states('sensor.ot_dhw') == "1" %} + gas + {% else %} + off + {% endif %} + qos: 0 + availability_topic: "tele/tasmota_1AA4E8/LWT" + payload_available: "Online" + payload_not_available: "Offline" + temperature_unit: C + min_temp: 40 + max_temp: 65 + - name: "piec_woda_ogrzewanie" + temperature_command_topic: "cmnd/tasmota_1AA4E8/OT_TBOILER" + temperature_state_topic: "tele/tasmota_1AA4E8/SENSOR" + temperature_state_template: "{{ value_json.OPENTHERM.BTMP.ACT }}" + current_temperature_topic: "tele/tasmota_1AA4E8/SENSOR" + current_temperature_template: "{{ value_json.OPENTHERM.OT33 }}" + modes: + - "off" + - "gas" + mode_command_topic: "cmnd/tasmota_1AA4E8/OT_CH" + mode_command_template: > + {% set values = { 'gas':'1', 'off':'0'} %} + {% set cmd = values[value] %} + {{ cmd }} + mode_state_topic: "tele/tasmota_1AA4E8/SENSOR" + mode_state_template: > + {% if states('sensor.ot_ch') == "1" %} + gas + {% else %} + off + {% endif %} + qos: 0 + availability_topic: "tele/tasmota_1AA4E8/LWT" + payload_available: "Online" + payload_not_available: "Offline" + temperature_unit: C + min_temp: 30 + max_temp: 70 + +# mqttx - gui diff --git a/roles/servers/apps/home-assistant/files/config/template.yaml b/roles/servers/apps/home-assistant/files/config/template.yaml index be9aed0f..741c8be4 100644 --- a/roles/servers/apps/home-assistant/files/config/template.yaml +++ b/roles/servers/apps/home-assistant/files/config/template.yaml @@ -11,3 +11,14 @@ # {%- elif now().hour >= 19 and now().hour < 24 -%} # https://www.meteo.pl/um/metco/mgram_pict.php?ntype=0u&fdate={{ now().strftime('%Y%m%d') }}12&row=466&col=232&lang=pl # {%- endif %} + +- sensor: + - name: current_state_ch + state: > + {% if states('sensor.opentherm_opentherm_slave_dhw') == "1" %} + Water + {% elif states('sensor.opentherm_opentherm_slave_ch') == "1" %} + CH + {% else %} + Idle + {% endif %} diff --git a/roles/servers/apps/home-assistant/tasks/config.yml b/roles/servers/apps/home-assistant/tasks/config.yml index 581f0132..86f3b670 100644 --- a/roles/servers/apps/home-assistant/tasks/config.yml +++ b/roles/servers/apps/home-assistant/tasks/config.yml @@ -6,6 +6,7 @@ loop: - "{{ install_path }}/config" - "{{ install_path }}/config/automations" + - "{{ install_path }}/config/sensors" - "{{ install_path }}/config/.storage" - "{{ install_path }}/config/mqtt/binary_sensors" - "{{ install_path }}/config/mqtt/sensors" @@ -42,6 +43,17 @@ - ../templates/config/automations/* - "{{ playbook_dir }}/../../ansible-ops-private/templates/home-assistant/config/automations/*" +- name: Configure config/sensors + template: + src: "{{ item }}" + dest: "{{ install_path }}/config/sensors/" + mode: 0664 + backup: true + with_fileglob: + - ../templates/config/sensors/* + - "{{ playbook_dir }}/../../ansible-ops-private/templates/home-assistant/config/sensors/*" + + - name: Configure config/mqtt/sensors template: src: "{{ item }}" @@ -78,6 +90,15 @@ with_fileglob: - ../templates/config/mqtt/switches/* +- name: Configure config/mqtt/water_heater + template: + src: "{{ item }}" + dest: "{{ install_path }}/config/mqtt/water_heater/" + mode: 0664 + backup: true + with_fileglob: + - ../templates/config/mqtt/water_heater/* + - name: Check that the .storage exists stat: path: "{{ install_path }}/config/.storage/onboarding" diff --git a/roles/servers/apps/home-assistant/templates/config/automations/automations.yaml b/roles/servers/apps/home-assistant/templates/config/automations/automations.yaml index 5c5a4ae2..d7340e18 100644 --- a/roles/servers/apps/home-assistant/templates/config/automations/automations.yaml +++ b/roles/servers/apps/home-assistant/templates/config/automations/automations.yaml @@ -11,7 +11,7 @@ - service: switch.turn_on data: {} target: - entity_id: switch.gosund_pompa_gosund_switch_pompa_cyrkulacyjna + entity_id: switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_cyrkulacyjna mode: single - alias: Wylacz cyrkulacje description: '' @@ -25,7 +25,35 @@ - service: switch.turn_off data: {} target: - entity_id: switch.gosund_pompa_gosund_switch_pompa_cyrkulacyjna + entity_id: switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_cyrkulacyjna + mode: single +- alias: Wlacz Grzejniki + description: '' + trigger: + - platform: time + at: 06:30:00 + - platform: time + at: '18:30:00' + condition: [] + action: + - service: switch.turn_on + data: {} + target: + entity_id: switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_grzejniki + mode: single +- alias: Wylacz Grzejniki + description: '' + trigger: + - platform: time + at: '07:00:00' + - platform: time + at: '19:00:00' + condition: [] + action: + - service: switch.turn_off + data: {} + target: + entity_id: switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_grzejniki mode: single - alias: Click button to close dwor_brama description: '' @@ -49,7 +77,7 @@ - trigger: state entity_id: {% for i in home_assistant.climate %} - - switch.virtual_ogrzewanie_{{ i.name }} + - "{{ i.switch }}" {% endfor %} from: "off" to: "on" @@ -59,7 +87,7 @@ metadata: {} data: {} target: - entity_id: switch.virtual_ogrzewanie_pompy + entity_id: switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_podlogowka mode: single - alias: ogrzewanie_wylacz description: "" @@ -85,7 +113,7 @@ metadata: {} data: {} target: - entity_id: switch.virtual_ogrzewanie_pompy + entity_id: switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_podlogowka mode: single # - alias: Alert Brama diff --git a/roles/servers/apps/home-assistant/templates/config/automations/piec.yaml b/roles/servers/apps/home-assistant/templates/config/automations/piec.yaml new file mode 100644 index 00000000..e11f8097 --- /dev/null +++ b/roles/servers/apps/home-assistant/templates/config/automations/piec.yaml @@ -0,0 +1,99 @@ +--- +- alias: piec_off + description: "" + mode: single + triggers: + - trigger: state + entity_id: + - >- + switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_podlogowka + from: "on" + to: "off" + for: + hours: 0 + minutes: 0 + seconds: 15 + conditions: [] + actions: + - action: water_heater.set_operation_mode + metadata: {} + data: + operation_mode: "off" + target: + entity_id: water_heater.piec_woda_ogrzewanie + - action: water_heater.set_temperature + metadata: {} + data: + temperature: 35 + target: + entity_id: water_heater.piec_woda_ogrzewanie +- alias: piec_on + description: "" + mode: single + triggers: + - trigger: state + entity_id: + - >- + switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_podlogowka + from: "off" + to: "on" + for: + hours: 0 + minutes: 0 + seconds: 15 + conditions: [] + actions: + - action: water_heater.set_operation_mode + metadata: {} + data: + operation_mode: "gas" + target: + entity_id: water_heater.piec_woda_ogrzewanie + - action: water_heater.set_temperature + metadata: {} + data: + temperature: 58 + target: + entity_id: water_heater.piec_woda_ogrzewanie +- alias: piec_palnik + description: "" + mode: single + triggers: + - trigger: numeric_state + entity_id: + - sensor.opentherm_opentherm_slave_fl + above: 0 + conditions: + - condition: numeric_state + entity_id: sensor.opentherm_opentherm_slave_ch + above: 0 + actions: + - action: water_heater.set_temperature + metadata: {} + data: + temperature: 60 + target: + entity_id: water_heater.piec_woda_ogrzewanie + - wait_for_trigger: + - trigger: numeric_state + entity_id: + - sensor.opentherm_opentherm_flm + for: + hours: 0 + minutes: 1 + seconds: 0 + above: 0 + continue_on_timeout: false + enabled: false + - delay: + hours: 0 + minutes: 10 + seconds: 0 + milliseconds: 0 + enabled: true + - action: water_heater.set_temperature + metadata: {} + data: + temperature: 40 + target: + entity_id: water_heater.piec_woda_ogrzewanie diff --git a/roles/servers/apps/home-assistant/templates/config/climate.yaml b/roles/servers/apps/home-assistant/templates/config/climate.yaml index cdc0b162..11c60d0a 100644 --- a/roles/servers/apps/home-assistant/templates/config/climate.yaml +++ b/roles/servers/apps/home-assistant/templates/config/climate.yaml @@ -2,12 +2,12 @@ {% for i in home_assistant.climate %} - platform: generic_thermostat name: "{{ i.name }}" - # heater: "{{ i.switch }}" - heater: "switch.virtual_ogrzewanie_{{ i.name }}" + heater: "{{ i.switch }}" + # heater: "switch.virtual_ogrzewanie_{{ i.name }}" target_sensor: "sensor.th_{{ i.name }}_temperature" min_temp: 16 max_temp: 24 - target_temp: 20.0 + # target_temp: 20.0 initial_hvac_mode: heat cold_tolerance: 0.2 hot_tolerance: 0.2 diff --git a/roles/servers/apps/home-assistant/templates/config/mqtt/water_heater/opentherm.yaml b/roles/servers/apps/home-assistant/templates/config/mqtt/water_heater/opentherm.yaml new file mode 100644 index 00000000..ea524a94 --- /dev/null +++ b/roles/servers/apps/home-assistant/templates/config/mqtt/water_heater/opentherm.yaml @@ -0,0 +1,75 @@ +{# - name: "piec_ciepla_woda_uzytkowa" + temperature_command_topic: "cmnd/tasmota_1AA4E8/OT_TWATER" + temperature_state_topic: "tele/tasmota_1AA4E8/SENSOR" + temperature_state_template: "{% raw %}{{ value_json.OPENTHERM.DHWS }}" + current_temperature_topic: "tele/tasmota_1AA4E8/SENSOR" + current_temperature_template: "{% raw %}{{ value_json.OPENTHERM.TDHW }}" + modes: + - "off" + - "gas" + # mode_command_topic: "cmnd/tasmota_1AA4E8/OT_CH" + # mode_command_template: > + # {% set values = { 'gas':'1', 'off':'0'} %} + # {% set cmd = values[value] %} + # {{ cmd }} + mode_state_topic: "tele/tasmota_1AA4E8/SENSOR" + mode_state_template: > + {% raw %}{% if value_json.OPENTHERM.SLAVE.DHW == 1 %} + gas + {% raw %}{% else %} + off + {% endif %}{% endraw +%} + qos: 0 + availability_topic: "tele/tasmota_1AA4E8/LWT" + payload_available: "Online" + payload_not_available: "Offline" + temperature_unit: C + # target_temperature: 55 + min_temp: 30 + max_temp: 65 + +- name: "piec_woda_ogrzewanie" + temperature_command_topic: "cmnd/tasmota_1AA4E8/OT_TBOILER" + temperature_state_topic: "tele/tasmota_1AA4E8/SENSOR" + temperature_state_template: "{% raw %}{{{ value_json.OPENTHERM.BTMP.ACT }}" + current_temperature_topic: "tele/tasmota_1AA4E8/SENSOR" + # current_temperature_template: "{{ value_json.OPENTHERM.TB }}" + current_temperature_template: "{% raw %}{{ value_json.OPENTHERM.OT33 }}" + modes: + - "off" + - "gas" + mode_command_topic: "cmnd/tasmota_1AA4E8/OT_CH" + # mode_command_template: > + # {% if value == gas %} + # 1 + # {% else %} + # 0 + # {% endif %} + mode_command_template: > + {% set values = { 'gas':'1', 'off':'0'} %} + {% set cmd = values[value] %} + {% raw %}{{ cmd }} + mode_state_topic: "tele/tasmota_1AA4E8/sensor_ch" + # mode_state_template: "{{ value_json.OPENTHERM.SLAVE.CH }}" + mode_state_template: > + {% raw %}{% if value_json.ot_ch == 1 %} + gas + {% raw %}{% else %} + off + {% endif %}{% endraw +%} + # mode_state_template: > + # {% raw %}{% if value_json.OPENTHERM.SLAVE.CH == 1 %} + # gas + # {% raw %}{% else %} + # off + # {% endif %}{% endraw +%} + qos: 0 + availability_topic: "tele/tasmota_1AA4E8/LWT" + payload_available: "Online" + payload_not_available: "Offline" + temperature_unit: C + # target_temperature: 55 + min_temp: 30 + max_temp: 65 + +# mqttx - gui #} diff --git a/roles/servers/apps/home-assistant/files/config/sensors.yaml b/roles/servers/apps/home-assistant/templates/config/sensors/saj.yaml similarity index 100% rename from roles/servers/apps/home-assistant/files/config/sensors.yaml rename to roles/servers/apps/home-assistant/templates/config/sensors/saj.yaml diff --git a/roles/servers/apps/home-assistant/templates/config/switch.yaml b/roles/servers/apps/home-assistant/templates/config/switch.yaml index 2f6cf585..f3d0ca4c 100644 --- a/roles/servers/apps/home-assistant/templates/config/switch.yaml +++ b/roles/servers/apps/home-assistant/templates/config/switch.yaml @@ -11,5 +11,11 @@ name: group_ogrzewanie_podlogowe entities: {% for i in home_assistant.climate %} - - switch.virtual_ogrzewanie_{{ i.name }} + - "{{ i.switch }}" {% endfor %} + +- platform: group + name: group_ogrzewanie_pokoj_timi + entities: + - switch.sonoff_4chpror3_ogrzewanie_gora2_sonoff_4chpror3_ogrzewanie_gora2_pokoj_timi + - switch.sonoff_4chpror3_ogrzewanie_gora2_sonoff_4chpror3_ogrzewanie_gora2_korytarz diff --git a/roles/servers/apps/home-assistant/templates/config/ui-lovelace.yaml b/roles/servers/apps/home-assistant/templates/config/ui-lovelace.yaml index 6b204366..d013cf91 100644 --- a/roles/servers/apps/home-assistant/templates/config/ui-lovelace.yaml +++ b/roles/servers/apps/home-assistant/templates/config/ui-lovelace.yaml @@ -108,18 +108,18 @@ views: name: Wilgotnosc - entity: sensor.th_pokoj_timi_battery name: Bateria - # - entity: sensor.th_lazienka_gora_temperature - # type: custom:multiple-entity-row - # name: Pokoj Timi - # show_state: false - # secondary_info: last-changed - # entities: - # - entity: sensor.th_lazienka_gora_temperature - # name: Temperatura - # - entity: sensor.th_lazienka_gora_humidity - # name: Wilgotnosc - # - entity: sensor.th_lazienka_gora_battery - # name: Bateria + - entity: sensor.th_lazienka_gora_temperature + type: custom:multiple-entity-row + name: Pokoj Timi + show_state: false + secondary_info: last-changed + entities: + - entity: sensor.th_lazienka_gora_temperature + name: Temperatura + - entity: sensor.th_lazienka_gora_humidity + name: Wilgotnosc + - entity: sensor.th_lazienka_gora_battery + name: Bateria - entity: sensor.th_biuro_miki_temperature type: custom:multiple-entity-row name: Biuro Miki @@ -156,18 +156,18 @@ views: name: Wilgotnosc - entity: sensor.th_garderoba_battery name: Bateria - - entity: sensor.th_serwerownia_temperature - type: custom:multiple-entity-row - name: Serwerownia - show_state: false - secondary_info: last-changed - entities: - - entity: sensor.th_serwerownia_temperature - name: Temperatura - - entity: sensor.th_serwerownia_humidity - name: Wilgotnosc - - entity: sensor.th_serwerownia_battery - name: Bateria + # - entity: sensor.th_serwerownia_temperature + # type: custom:multiple-entity-row + # name: Serwerownia + # show_state: false + # secondary_info: last-changed + # entities: + # - entity: sensor.th_serwerownia_temperature + # name: Temperatura + # - entity: sensor.th_serwerownia_humidity + # name: Wilgotnosc + # - entity: sensor.th_serwerownia_battery + # name: Bateria - entity: sensor.th_pokoj_julia_temperature type: custom:multiple-entity-row name: Pokoj Julia @@ -237,18 +237,6 @@ views: entities: - entity: sensor.gosund_monitory_energy_power name: Zuzycie - - entity: switch.gosund_pompa_gosund_switch_pompa_cyrkulacyjna - type: custom:multiple-entity-row - name: Pompa Cyrkulacyjna - icon: mdi:thermometer-water - toggle: true - show_state: true - entities: - - entity: automation.wlacz_cyrkulacje - name: Auto - toggle: true - - entity: sensor.gosund_pompa_energy_power - name: Zuzycie - entity: switch.gosund_pc_gosund_switch_pc type: custom:multiple-entity-row name: PC @@ -583,35 +571,111 @@ views: path: ogrzewanie badges: [] cards: + - type: history-graph + entities: + - name: Slave_FL + entity: sensor.opentherm_opentherm_slave_fl + - name: FLM + entity: sensor.opentherm_opentherm_flm + - name: TB + entity: sensor.opentherm_opentherm_tb + - name: OT33 (EXHAUST CH) + entity: sensor.opentherm_opentherm_ot33 + - name: CH_TEMP + entity: sensor.opentherm_opentherm_btmp_req + - name: Slave_CH + entity: sensor.opentherm_opentherm_slave_ch + - name: State + entity: sensor.current_state_ch + - name: CH_STATE + entity: sensor.ot_ch + hours_to_show: 4 + logarithmic_scale: false + max_y_axis: 100 + min_y_axis: 0 + fit_y_data: false - type: entities entities: - - switch.virtual_ogrzewanie_pompy + - entity: sensor.opentherm_opentherm_tb + type: custom:multiple-entity-row + name: Piec + show_state: false + secondary_info: last-changed + entities: + - entity: sensor.opentherm_opentherm_flm + name: FLM + - entity: sensor.opentherm_opentherm_slave_fl + name: SLAVE FL + - entity: sensor.current_state_ch + name: State + - entity: sensor.opentherm_opentherm_slave_ch + name: CH + - entity: sensor.opentherm_opentherm_slave_dhw + name: DHW + - entity: sensor.opentherm_opentherm_tb + name: TB + - entity: water_heater.piec_woda_ogrzewanie + name: Ogrzewanie + icon: mdi:heating-coil + state_color: true + - entity: water_heater.piec_ciepla_woda_uzytkowa + name: CWU + icon: mdi:water-boiler + state_color: true + - type: section + label: Pompy + - entity: switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_podlogowka + name: Pompa Podlogowka + - entity: switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_grzejniki + name: Pompa Grzejniki + - entity: switch.sonoff_4chpror3_ogrzewanie_piec_sonoff_4chpror3_ogrzewanie_piec_pompa_cyrkulacyjna + type: custom:multiple-entity-row + name: Pompa Cyrkulacyjna + icon: mdi:thermometer-water + toggle: true + show_state: true + entities: + - entity: automation.wlacz_cyrkulacje + name: Auto + toggle: true + # - entity: sensor.gosund_pompa_energy_power + # name: Zuzycie + - type: section + label: Virtual - switch.group_ogrzewanie_podlogowe - type: section label: Silowniki {% for i in home_assistant.climate %} - - switch.virtual_ogrzewanie_{{ i.name }} + - entity: {{ i.switch }} + name: {{ i.name }} {% endfor %} -{% for i in home_assistant.climate %} +{# {% for i in home_assistant.climate %} - type: thermostat entity: climate.{{ i.name }} -{% endfor %} + features: + - type: climate-hvac-modes + hvac_modes: + - heat + - 'off' +{% endfor %} #} - type: entities - title: Temperatury Zigbee + title: Termostaty entities: - - entity: climate.kuchnia +{% for i in home_assistant.climate %} + - entity: climate.{{ i.name }} type: custom:multiple-entity-row - name: Kuchnia + name: {{ i.name }} show_state: false - secondary_info: last-changed + state_color: true + secondary_info: last-updated entities: - - entity: climate.kuchnia - name: Termostat - name: Termostat Stan - - entity: sensor.th_kuchnia_temperature - name: Temperatura - - entity: sensor.th_kuchnia_humidity - name: Wilgotnosc - - entity: sensor.th_kuchnia_battery - name: Bateria + - entity: climate.{{ i.name }} + attribute: hvac_action + name: State + - entity: climate.{{ i.name }} + attribute: temperature + name: Target Temperature + - entity: sensor.th_{{ i.name }}_temperature + name: Current Temperature +{% endfor %} title: MikiDashboardYAML diff --git a/roles/servers/bootstrap/handlers/main.yml b/roles/servers/bootstrap/handlers/main.yml new file mode 100644 index 00000000..349e77c8 --- /dev/null +++ b/roles/servers/bootstrap/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: restart_ssh + service: + name: sshd + state: restarted diff --git a/roles/servers/bootstrap/tasks/main.yml b/roles/servers/bootstrap/tasks/main.yml index a00261f4..2168505b 100644 --- a/roles/servers/bootstrap/tasks/main.yml +++ b/roles/servers/bootstrap/tasks/main.yml @@ -1,3 +1,8 @@ --- - import_tasks: user.yml - import_tasks: ssh_keys.yml + +- meta: flush_handlers +# 206 - 1st dol +# 205 - 2nd dol +# 203 - piec diff --git a/roles/servers/bootstrap/tasks/ssh_keys.yml b/roles/servers/bootstrap/tasks/ssh_keys.yml index 64e26be9..7d8a2bcc 100644 --- a/roles/servers/bootstrap/tasks/ssh_keys.yml +++ b/roles/servers/bootstrap/tasks/ssh_keys.yml @@ -1,12 +1,36 @@ --- +- name: Create directory for ssh + file: + path: "~{{ item }}/.ssh" + state: directory + mode: 0700 + owner: "{{ item }}" + group: "{{ item }}" + with_items: + - "{{ user_name }}" + - deploy + # - root + - name: Copy ssh pub key template: src: "{{ ssh_keys_path }}/servers/id_rsa.pub" - dest: "~/.ssh/authorized_keys" + dest: "~{{ item }}/.ssh/authorized_keys" mode: 0600 backup: true - become: true - become_user: "{{ item }}" + owner: "{{ item }}" + group: "{{ item }}" with_items: - "{{ user_name }}" + - deploy # - root + +- name: Disable ssh key auth + lineinfile: + dest: "{{ item }}" + regexp: ^PasswordAuthentication + line: PasswordAuthentication no + ignore_errors: true + notify: restart_ssh + loop: + - /etc/ssh/sshd_config + - /etc/ssh/sshd_config.d/50-cloud-init.conf diff --git a/roles/servers/bootstrap/tasks/user.yml b/roles/servers/bootstrap/tasks/user.yml index ed97d539..33aea831 100644 --- a/roles/servers/bootstrap/tasks/user.yml +++ b/roles/servers/bootstrap/tasks/user.yml @@ -1 +1,18 @@ --- +- name: Add the user 'deploy' + ansible.builtin.user: + name: deploy + uid: 1999 + groups: wheel + create_home: true + append: true + shell: /bin/zsh + password_lock: true + +- name: Make users passwordless for sudo in group wheel + lineinfile: + path: /etc/sudoers + state: present + regexp: '^%wheel' + line: '%wheel ALL=(ALL) NOPASSWD: ALL' + validate: 'visudo -cf %s'