Skip to content

Commit

Permalink
Add Tasmota OpenTherm to HA (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeeq committed Dec 12, 2024
1 parent 573bc47 commit 8b08294
Show file tree
Hide file tree
Showing 18 changed files with 517 additions and 135 deletions.
14 changes: 14 additions & 0 deletions playbooks/vms.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
---
- name: Bootstrap host
hosts: localhost
become: false
tasks:
# - name: Change private key permissions
# ansible.builtin.raw: >-
# chmod -c 644 {{ ansible_ssh_private_key_file }}
# register: private_key_perms
# changed_when: private_key_perms.stdout != ""
- name: Change private key permissions
file:
path: "{{ ansible_ssh_private_key_file }}"
mode: 0600

- name: Fedora on Clevo
ansible.builtin.import_playbook: fedora.yml
vars:
Expand Down
36 changes: 21 additions & 15 deletions roles/servers/apps/home-assistant/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ virtual:
switch: !include switch.yaml
climate: !include climate.yaml

rest:
# scan_interval: 10

zha:
zigpy_config:
Expand Down

This file was deleted.

60 changes: 60 additions & 0 deletions roles/servers/apps/home-assistant/files/config/mqtt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions roles/servers/apps/home-assistant/files/config/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
21 changes: 21 additions & 0 deletions roles/servers/apps/home-assistant/tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand All @@ -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: ''
Expand All @@ -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"
Expand All @@ -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: ""
Expand All @@ -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
Expand Down
Loading

0 comments on commit 8b08294

Please sign in to comment.