Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds documentation for MyStrom EU Switch #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
matrix:
file:
- mystrom-switch-v2.yaml
- mystrom-switch-eu.yaml
steps:
- name: Checkout source code
uses: actions/checkout@v2
Expand Down
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
| :------------- | :------------------------------------------------- |
| WiFi Switch V1 | Not supported, incompatible chipset. |
| WiFi Switch V2 | [mystrom-switch-v2.yaml](./mystrom-switch-v2.yaml) |
| WiFi Switch EU | [mystrom-switch-eu.yaml](./mystrom-switch-eu.yaml) |

##  WiFi Switch v2

Expand All @@ -12,11 +13,11 @@ ESPHome support for the MyStrom V2 Wifi Switch. Currently the following features
- Control the relay
- Control the red and white LED
- Side and bottom buttons (same function)
- Energy monitoring and reporting (room for improvement)
- Energy monitoring and reporting
- Reading the internal temperature sensor
- Emergency power off if the internal temperature is to high

### WiFi Switch Pinout
### Pinout

```txt
JP1
Expand Down Expand Up @@ -44,3 +45,29 @@ Connect a UART programmer to the WiFi Switch in the following way:
| GPIO0 | GND |

If you use dupont wires it may be possible to connect these without soldering.

## WiFi Switch EU

### Pinout
@MajorBug reports the pinout to be the following

```txt
JP1
GND [] () RXD
GND () () TXD
GND () () GPIO0
GND () ()
GND () ()
VCC () ()
VCC () ()
() ()
() ()
```

###  Flashing

See above

# Thanks

Thanks to @MajorBug for contributing the Wifi Switch EU
172 changes: 172 additions & 0 deletions mystrom-switch-eu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
esphome:
friendly_name: myStrom Switch
name: mystrom-switch

esp32:
board: esp32doit-devkit-v1
framework:
type: esp-idf
sdkconfig_options:
COMPILER_OPTIMIZATION_SIZE: y
advanced:
ignore_efuse_mac_crc: true

# Enable logging
logger:
level: WARN

# Enable Home Assistant API
api:
encryption:
key: " "

ota:


wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-myStrom"
password: " "

enable_btm: True
enable_rrm: True

captive_portal:


# Enable NTP
time:
- platform: sntp
id: my_time

preferences:
flash_write_interval: 5min


i2c:
sda: 22
scl: 19
scan: false

light:
- platform: binary
name: "Identify LED"
disabled_by_default: true
restore_mode: RESTORE_DEFAULT_OFF
output: output_mystrom_led_red
- platform: binary
id: light_mystrom_status
restore_mode: RESTORE_DEFAULT_ON
output: output_mystrom_led_white

output:
- id: output_mystrom_led_red
platform: gpio
pin: GPIO16
inverted: false
- id: output_mystrom_led_white
platform: gpio
pin: GPIO17
inverted: true

binary_sensor:
- platform: gpio
pin:
number: GPIO23
mode:
input: true
pullup: true
inverted: true
id: button_mystrom_side
on_press:
then:
- switch.toggle: switch_mystrom_relay
- platform: gpio
pin:
number: GPIO18
mode:
input: true
pullup: true
inverted: true
id: button_mystrom_bottom
on_press:
then:
- switch.toggle: switch_mystrom_relay

sensor:
- platform: pulse_counter
pin: 4
update_interval: 10s
id: sensor_mystrom_energy_usage
name: "Power"
unit_of_measurement: "W"
accuracy_decimals: 0
filters:
# Map from sensor -> measured value
- calibrate_linear:
- 0.0 -> 1.55
- 2698.5 -> 85
- 4397.25 -> 146
- 30900 -> 1005
- 44634.56 -> 1439
- 59643.75 -> 1930
# Make everything below 1W appear as just 0W.
# Furthermore it corrects 1.55W for the power usage of the plug.
- lambda: if (x < (1 + 1.55)) return 0; else return (x - 1.55);

- platform: total_daily_energy
name: "Total Daily Energy"
power_id: sensor_mystrom_energy_usage
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
accuracy_decimals: 1

- platform: shtcx
id: sensor_mystrom_temperature
temperature:
name: "Internal Temperature"
on_value_range:
above: 80
then:
- switch.turn_off: switch_mystrom_relay
humidity:
name: "Internal Humidity"
update_interval: 60s
address: 0x70


- platform: uptime
name: Uptime
entity_category: "diagnostic"

# Reports the WiFi signal strength/RSSI in dB
- platform: wifi_signal
name: "WiFi Strength"
id: wifi_signal_db
update_interval: 60s
#Converts the WiFi signal strength to %
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: "diagnostic"

switch:
- platform: gpio
name: "Relay"
pin: GPIO27
id: switch_mystrom_relay
restore_mode: RESTORE_DEFAULT_ON
on_turn_on:
- output.turn_on: output_mystrom_led_white
on_turn_off:
- output.turn_off: output_mystrom_led_white

button:
- platform: restart
name: "Restart"