diff --git a/hall-switch-1.yaml b/hall-switch-1.yaml new file mode 100644 index 0000000..31a7cfe --- /dev/null +++ b/hall-switch-1.yaml @@ -0,0 +1,57 @@ +#SONOFF T1 EU/UK (1 button) +#https://www.banggood.com/SONOFF-T1-EU-or-UK-AC-100-240V-1-or-2-or-3-Gang-TX-Series-WIFI-Wall-Switch-433Mhz-RF-Remote-Controlled-Wifi-Switch-Smart-Home-Switch-Works-With-Alexa-Google-Home-p-1470883.html?rmmds=myorder&cur_warehouse=UK&ID=6278514 + +esphome: + name: hall_switch_1 + platform: ESP8266 + board: esp01_1m + +wifi: + ssid: !secret wifi-ssid + password: !secret wifi-password + +logger: +api: +ota: + +# This is the button on the switch +# It is no longer published to home assistant, it is instead used by esphome to +# update the state of a "virtual" sensor. This is how I distinguish +# between a single, double and hold push +binary_sensor: + - platform: gpio + name: "Hall Switch 1 Sensor" + pin: + number: GPIO0 + mode: INPUT_PULLUP + inverted: True + # There is a bit of a delay between pushing the button on the switch and + # the light turning on. This is for 2 main reasons: + # * There is a bit of a delay for the switch to decide if a single or + # double press was wanted + # * The smart bulbs take a little while to turn on + # To give some instant feedback to the user, I re-purpose the wifi light. + # Whenever the touchpad is being pushed, the light is on. + # This makes it clear that the push has been registered. + on_press: + then: + - output.turn_on: blue_led + on_release: + then: + - output.turn_off: blue_led + +# This switch gives electrisity to the bulb. We want it on all the time really +switch: + - platform: gpio + name: "Hall Switch Relay" + pin: GPIO12 + restore_mode: ALWAYS_ON + +# This is the blue wifi led. +# It is used above to determine whether or not a push is registered +output: + - platform: esp8266_pwm + id: blue_led + pin: GPIO13 + inverted: True + diff --git a/kitchen-lamp.yaml b/kitchen-lamp.yaml new file mode 100644 index 0000000..84bb396 --- /dev/null +++ b/kitchen-lamp.yaml @@ -0,0 +1,65 @@ +#SONOFF BASICR2 +#https://www.banggood.com/SONOFF-BASICR2-10A-2200W-WIFI-Wireless-Smart-Switch-Remote-Control-Socket-APP-Timer-AC90-250V-50-or-60Hz-Works-with-Amazon-Alexa-Google-Home-Assistant-Nest-IFTTT-p-1019971.html?rmmds=myorder&cur_warehouse=CN + +esphome: + name: kitchen_lamp + platform: ESP8266 + board: esp8285 + +wifi: + ssid: !secret wifi-ssid + password: !secret wifi-password + +logger: +api: +ota: + +# Device Specific Config + +light: + - platform: binary + id: lamp + name: "Kitchen Lamp" + output: gpio_12 +output: + - platform: gpio + pin: GPIO12 + id: gpio_12 + +binary_sensor: + - platform: gpio + id: push_button + pin: + number: GPIO0 + mode: INPUT_PULLUP + inverted: True + internal: true + on_press: + # Prevents unintended LED lit states. + if: + condition: + - light.is_off: lamp + then: + #- light.turn_on: blue_led + - light.turn_on: lamp + else: + - light.turn_off: lamp + +#switch: +# # The relay switches on the red side of the LED when active. +# - platform: gpio +# name: "Sonoff Basic Relay" +# pin: GPIO12 +# id: relay +# on_turn_off: +# if: +# condition: +# - switch.is_on: blue_led +# then: +# - switch.turn_off: blue_led +# # With this we can control the blue side of the LED. +# - platform: gpio +# id: blue_led +# pin: +# number: GPIO13 +# inverted: True diff --git a/kitchen-switch.yaml b/kitchen-switch.yaml new file mode 100644 index 0000000..e7909ff --- /dev/null +++ b/kitchen-switch.yaml @@ -0,0 +1,164 @@ +#SONOFF T1 EU/UK (3 buttons) +#https://www.banggood.com/SONOFF-T1-EU-or-UK-AC-100-240V-1-or-2-or-3-Gang-TX-Series-WIFI-Wall-Switch-433Mhz-RF-Remote-Controlled-Wifi-Switch-Smart-Home-Switch-Works-With-Alexa-Google-Home-p-1470883.html?rmmds=myorder&cur_warehouse=UK&ID=6278514 + +esphome: + name: kitchen_switch + platform: ESP8266 + board: esp01_1m + +wifi: + ssid: !secret wifi-ssid + password: !secret wifi-password + +logger: +api: +ota: + +binary_sensor: + + - platform: gpio + pin: + number: GPIO0 + mode: INPUT_PULLUP + inverted: True + name: "Kitchen Touchpad 1" + on_press: + then: + - output.turn_on: blue_led + on_release: + then: + - output.turn_off: blue_led + + - platform: gpio + pin: + number: GPIO9 + mode: INPUT_PULLUP + inverted: True + name: "Kitchen Touchpad 2" + on_press: + if: + condition: + - light.is_off: kitchen_celing_light + then: + - light.turn_on: kitchen_celing_light + - output.turn_on: blue_led + else: + - light.turn_off: kitchen_celing_light + - output.turn_on: blue_led + on_release: + then: + output.turn_off: blue_led + + - platform: gpio + pin: + number: GPIO10 + mode: INPUT_PULLUP + inverted: True + name: "Kitchen Touchpad 3" + on_press: + if: + condition: + - light.is_off: under_lights_light + then: + - light.turn_on: under_lights_light + - output.turn_on: blue_led + else: + - light.turn_off: under_lights_light + - output.turn_on: blue_led + on_release: + then: + output.turn_off: blue_led + # - platform: status + # name: "Sonoff T1 UK 3 Gang Status" + +switch: + - platform: gpio + name: "Lounge Relay 1" + pin: GPIO12 + restore_mode: ALWAYS_OFF +# - platform: gpio +# name: "Lounge Relay 2" +# pin: GPIO5 +# - platform: gpio +# name: "Lounge Relay 3" +# pin: GPIO4 + + +output: + # Register the blue LED as a dimmable output .... + - platform: esp8266_pwm + id: blue_led + pin: GPIO13 + inverted: True + - platform: gpio + id: kitchen_celing + pin: GPIO5 + - platform: gpio + id: under_lights + pin: GPIO4 + +light: + - platform: binary + name: "Kitchen Celing" + output: kitchen_celing + id: kitchen_celing_light + - platform: binary + name: "Kitchen Under Lighting" + output: under_lights + id: under_lights_light + + +# This sensor is published to homeassistant with the value: +# * single +# * double +# * hold +# This can be used to trigger automations by type "state" +#text_sensor: +# - platform: template +# name: "Lounge Touchpad 1" +# id: louge_button_1 +# icon: "mdi:toggle-switch" +# on_value: +# then: +# - if: +# condition: +# text_sensor.state: +# id: louge_button_1 +# state: "" +# else: +# - delay: 20ms +# - text_sensor.template.publish: +# id: louge_button_1 +# state: !lambda 'return "";' +# - platform: template +# name: "Lounge Touchpad 2" +# id: louge_button_2 +# icon: "mdi:toggle-switch" +# on_value: +# then: +# - if: +# condition: +# text_sensor.state: +# id: louge_button_2 +# state: "" +# else: +# - delay: 20ms +# - text_sensor.template.publish: +# id: louge_button_2 +# state: !lambda 'return "";' +# - platform: template +# name: "Lounge Touchpad 3" +# id: louge_button_3 +# icon: "mdi:toggle-switch" +# on_value: +# then: +# - if: +# condition: +# text_sensor.state: +# id: louge_button_3 +# state: "" +# else: +# - delay: 20ms +# - text_sensor.template.publish: +# id: louge_button_3 +# state: !lambda 'return "";' diff --git a/study-switch.yaml b/study-switch.yaml new file mode 100644 index 0000000..ed276c2 --- /dev/null +++ b/study-switch.yaml @@ -0,0 +1,57 @@ +#SONOFF T1 EU/UK (1 button) +#https://www.banggood.com/SONOFF-T1-EU-or-UK-AC-100-240V-1-or-2-or-3-Gang-TX-Series-WIFI-Wall-Switch-433Mhz-RF-Remote-Controlled-Wifi-Switch-Smart-Home-Switch-Works-With-Alexa-Google-Home-p-1470883.html?rmmds=myorder&cur_warehouse=UK&ID=6278514 + +esphome: + name: study_switch + platform: ESP8266 + board: esp01_1m + +wifi: + ssid: !secret wifi-ssid + password: !secret wifi-password + +logger: +api: +ota: + +# This is the button on the switch +# It is no longer published to home assistant, it is instead used by esphome to +# update the state of a "virtual" sensor. This is how I distinguish +# between a single, double and hold push +binary_sensor: + - platform: gpio + name: "Study Sensor" + pin: + number: GPIO0 + mode: INPUT_PULLUP + inverted: True + # There is a bit of a delay between pushing the button on the switch and + # the light turning on. This is for 2 main reasons: + # * There is a bit of a delay for the switch to decide if a single or + # double press was wanted + # * The smart bulbs take a little while to turn on + # To give some instant feedback to the user, I re-purpose the wifi light. + # Whenever the touchpad is being pushed, the light is on. + # This makes it clear that the push has been registered. + on_press: + then: + - output.turn_on: blue_led + on_release: + then: + - output.turn_off: blue_led + +# This switch gives electrisity to the bulb. We want it on all the time really +switch: + - platform: gpio + name: "Study Relay" + pin: GPIO12 + restore_mode: ALWAYS_ON + +# This is the blue wifi led. +# It is used above to determine whether or not a push is registered +output: + - platform: esp8266_pwm + id: blue_led + pin: GPIO13 + inverted: True +