From 1cdcbe53748edf8ebc065e5749923312d97b5fb6 Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Wed, 19 Jul 2023 17:00:09 +0200 Subject: [PATCH] Expand mystrom fleet --- .gitignore | 3 +- mystrom-car-charger.yaml | 24 ++++++++++++ mystrom-pool.yaml | 19 ++++++++++ mystrom-recirculation-pump.yaml | 19 ++++++++++ mystrom.yaml => templates/mystrom.yaml | 51 ++++++++++++++------------ 5 files changed, 92 insertions(+), 24 deletions(-) create mode 100644 mystrom-car-charger.yaml create mode 100644 mystrom-pool.yaml create mode 100644 mystrom-recirculation-pump.yaml rename mystrom.yaml => templates/mystrom.yaml (68%) diff --git a/.gitignore b/.gitignore index 6bf2aea..f97c623 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # Gitignore settings for ESPHome # This is an example and may include too much for your use-case. # You can modify this file to suit your needs. -/.esphome/ +.esphome/ **/.pioenvs/ **/.piolibdeps/ **/lib/ @@ -9,3 +9,4 @@ **/platformio.ini **/partitions.csv secrets.yaml +/templates/.gitignore diff --git a/mystrom-car-charger.yaml b/mystrom-car-charger.yaml new file mode 100644 index 0000000..553a8b5 --- /dev/null +++ b/mystrom-car-charger.yaml @@ -0,0 +1,24 @@ +substitutions: + name: "car-charger" + +packages: + device_base: !include templates/mystrom.yaml + +time: +- platform: sntp + on_time: + # SAK Schwachlast (T2) https://www.sak.ch/private/strom/strompreise2023 + # Montag bis Freitag: 00.00 bis 07.00 Uhr | 19.00 bis 24.00 Uhr + # Samstag bis Sonntag: 00.00 bis 24.00 Uhr + - hours: 19 + minutes: 0 + seconds: 0 + days_of_week: MON-FRI + then: + - switch.turn_on: mystrom_relay + - hours: 7 + minutes: 0 + seconds: 0 + days_of_week: MON-FRI + then: + - switch.turn_off: mystrom_relay diff --git a/mystrom-pool.yaml b/mystrom-pool.yaml new file mode 100644 index 0000000..ab82a03 --- /dev/null +++ b/mystrom-pool.yaml @@ -0,0 +1,19 @@ +substitutions: + name: "pool" + +packages: + device_base: !include templates/mystrom.yaml + +time: +- platform: sntp + on_time: + - hours: 9 + minutes: 55 + seconds: 0 + then: + - switch.turn_on: mystrom_relay + - hours: 21 + minutes: 55 + seconds: 0 + then: + - switch.turn_off: mystrom_relay diff --git a/mystrom-recirculation-pump.yaml b/mystrom-recirculation-pump.yaml new file mode 100644 index 0000000..a569ff5 --- /dev/null +++ b/mystrom-recirculation-pump.yaml @@ -0,0 +1,19 @@ +substitutions: + name: "recirculation-pump" + +packages: + device_base: !include templates/mystrom.yaml + +time: +- platform: sntp + on_time: + - hours: 4 + minutes: 30 + seconds: 0 + then: + - switch.turn_on: mystrom_relay + - hours: 20 + minutes: 0 + seconds: 0 + then: + - switch.turn_off: mystrom_relay diff --git a/mystrom.yaml b/templates/mystrom.yaml similarity index 68% rename from mystrom.yaml rename to templates/mystrom.yaml index 6f18f87..553c5c3 100644 --- a/mystrom.yaml +++ b/templates/mystrom.yaml @@ -17,9 +17,9 @@ esp32: type: esp-idf packages: - mqtt: !include templates/mqtt.yaml - ota: !include templates/ota.yaml - wifi: !include templates/wifi.yaml + mqtt: !include mqtt.yaml + ota: !include ota.yaml + wifi: !include wifi.yaml logger: @@ -73,33 +73,38 @@ binary_sensor: - switch.toggle: mystrom_relay sensor: -- platform: pulse_meter +- platform: pulse_counter pin: 4 + update_interval: 10s id: mystrom_power_consumption name: "${full_name} Power relay consumption" - - unit_of_measurement: "W" device_class: "power" state_class: "measurement" - - accuracy_decimals: 2 + unit_of_measurement: "W" + accuracy_decimals: 0 filters: - - multiply: 0.031 - - throttle_average: 5s - - filter_out: nan - - heartbeat: 35s + # Map from sensor -> measured value (pulse/min -> W), + # taken from https://github.com/mightea/esphome-mystrom-devices + - calibrate_linear: + - 0.0 -> 1.55 + - 2698.5 -> 85 + - 4397.25 -> 146 + - 30900 -> 1005 + - 44634.56 -> 1439 + - 59643.75 -> 1930 + # Correct 1.55W for the power usage of the plug. + - offset: -1.55 + # Make everything below 1W appear as just 0W. + - lambda: if (x < 1) return 0; return x; - total: - name: "${full_name} Power consumption total" - unit_of_measurement: "Wh" - device_class: "energy" - state_class: "total_increasing" - accuracy_decimals: 2 - filters: - - multiply: 0.000517 - - throttle_average: 5s - - filter_out: nan - - heartbeat: 35s +- platform: integration + sensor: mystrom_power_consumption + name: "${full_name} Power consumption total" + time_unit: "h" + unit_of_measurement: "Wh" + device_class: "energy" + state_class: "total_increasing" + accuracy_decimals: 2 - platform: tmp102 id: mystrom_temperature