Expand mystrom fleet

This commit is contained in:
2023-07-19 17:00:09 +02:00
parent b740de9079
commit 1cdcbe5374
5 changed files with 92 additions and 24 deletions
+124
View File
@@ -0,0 +1,124 @@
substitutions:
# Change this via CLI with:
# $ esphome -s name tools run mystrom.yaml
name: "spare"
full_name: "mystrom-${name}"
esphome:
name: "${full_name}"
project:
name: "dasfoo.${full_name}"
version: "1.0"
esp32:
board: esp32doit-devkit-v1
framework:
type: esp-idf
packages:
mqtt: !include mqtt.yaml
ota: !include ota.yaml
wifi: !include wifi.yaml
logger:
button:
- platform: restart
name: "${full_name} ESP chip restart"
i2c:
sda: 22
scl: 19
scan: false
status_led:
# Red LED on the front panel.
pin: GPIO16
light:
- platform: binary
name: "${full_name} Identify LED (white)"
id: mystrom_led_identify
restore_mode: ALWAYS_OFF
output: mystrom_led_white
output:
- id: mystrom_led_white
platform: gpio
pin: GPIO17
inverted: true
binary_sensor:
- platform: gpio
id: mystrom_side
name: "${full_name} Side button (plus) pressed"
pin:
number: GPIO23
mode:
input: true
pullup: true
inverted: true
- platform: gpio
id: mystrom_bottom
name: "${full_name} Bottom button (power) pressed"
pin:
number: GPIO18
mode:
input: true
pullup: true
inverted: true
on_press:
then:
- switch.toggle: mystrom_relay
sensor:
- platform: pulse_counter
pin: 4
update_interval: 10s
id: mystrom_power_consumption
name: "${full_name} Power relay consumption"
device_class: "power"
state_class: "measurement"
unit_of_measurement: "W"
accuracy_decimals: 0
filters:
# 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;
- 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
name: "${full_name} Internal temperature"
update_interval: 60s
address: 0x48
on_value_range:
above: 80
then:
- switch.turn_off: mystrom_relay
switch:
- platform: gpio
name: "${full_name} Power relay"
pin: GPIO27
id: mystrom_relay
restore_mode: RESTORE_DEFAULT_ON