From ee2c53585fc8572bffd496c8c17bc57691b9218c Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sun, 3 Jun 2018 13:00:40 +0200 Subject: [PATCH] Add Sonoff S20 example --- esphomeyaml/config_validation.py | 6 ++-- examples/sonoff_s20.yaml | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 examples/sonoff_s20.yaml diff --git a/esphomeyaml/config_validation.py b/esphomeyaml/config_validation.py index a3e00fd89d..6ae3932271 100644 --- a/esphomeyaml/config_validation.py +++ b/esphomeyaml/config_validation.py @@ -56,8 +56,10 @@ def alphanumeric(value): def valid_name(value): value = string_strict(value) - if not all(c in ALLOWED_NAME_CHARS for c in value): - raise vol.Invalid(u"Valid characters for name are {}".format(ALLOWED_NAME_CHARS)) + for c in value: + if c not in ALLOWED_NAME_CHARS: + raise vol.Invalid(u"'{}' is an invalid character for names. Valid characters are: {}" + u"".format(c, ALLOWED_NAME_CHARS)) return value diff --git a/examples/sonoff_s20.yaml b/examples/sonoff_s20.yaml new file mode 100644 index 0000000000..72eafef9e5 --- /dev/null +++ b/examples/sonoff_s20.yaml @@ -0,0 +1,50 @@ +esphomeyaml: + name: + platform: ESP8266 + board: esp01_1m + board_flash_mode: dout + +wifi: + ssid: + password: + +mqtt: + broker: + username: + password: + +logger: + +ota: + +binary_sensor: + - platform: gpio + pin: + number: GPIO0 + mode: INPUT_PULLUP + inverted: True + name: "Sonoff S20 Button" + on_press: + then: + - switch.toggle: + id: relay + - platform: status + name: "Sonoff S20 Status" + + +switch: + - platform: gpio + name: "Sonoff S20 Relay" + pin: GPIO12 + id: relay + +output: + - platform: esp8266_pwm + id: s20_green_led + pin: GPIO13 + inverted: True + +light: + - platform: monochromatic + name: "Sonoff S20 Green LED" + output: s20_green_led