diff --git a/.vscode/settings.json b/.vscode/settings.json index 6cce276..c2509ce 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,9 @@ { "cSpell.ignoreWords": [ "espressif", - "pioenvs" + "luntak", + "pioenvs", + "sonoff", + "tuya" ] } \ No newline at end of file diff --git a/README.md b/README.md index 69afd57..02ed3f7 100755 --- a/README.md +++ b/README.md @@ -13,6 +13,12 @@ I started with the [ESP32 Bluetooth Low Energy Tracker Hub][esphome-ble-hub] exa ### dog_water.yaml A **FAILED** attempt at making a dog water bowl sensor with an ESP8266 board. By inserting two insulated wires (cut at the end) into the bowl I hoped it would become a "switch" that would turn on and off when submerged in the water or dry. It did not work, someday I will try to find a more reliable way to sense water. +### Irrigation Controller: irrigation.yaml +#### [Sonoff 4ch Pro R2][esphome-sonoff4pro] +Our battery and cloud powered Melnor Raincloud/Aquatimer has been flaky off and on for years. Now even new batteries aren't resolving the problem. Also, there appears to be possible battery acid inside the battery compartment. I suspect the wireless radio may be dead despite being able to manually toggle the valves. + +The ESPHome projects I have done around our house have been extremely reliable and useful additions to our smart home. Recently, the ESPHome site featured a user's project that turned a Sonoff 4 channel Pro unit into an irrigation controller, which inspired me. That project features a nifty touch screen display. But I want to start simple. We can start with a dumb relay controller, with the brains being controlled from Home Assistant. + ### Standard plugs: plug01.yaml - plug03.yaml #### ZooZee brand Tuya plugs These are simple round wall plug were flashed with over the air with tasmota-convert, then ESPHome was uploaded via the Tasmota UI. The ESPHome code attempts to recreate their original functionality. @@ -20,7 +26,7 @@ These are simple round wall plug were flashed with over the air with tasmota-con ### Hot Water Pump: plug05.yaml This plug controls the whole house hot water recirculation pump. When we turn this on we don't want it to keep running forever. So I set a timeout that turns the pump off after 10 minutes. This timeout is a backup to the Home Assistant automation that automatically turns it off after 5 minutes. -### Standard plugs: plug06.yaml - plug08.yaml +### Standard plugs: plug04.yaml - plug07.yaml #### Luntak brand Tuya plugs These are simple round wall plugs were flashed with over the air with tasmota-convert, then ESPHome was uploaded via the Tasmota UI. The ESPHome code attempts to recreate their original functionality. @@ -38,7 +44,7 @@ The ESPHome code gets the humidity from Home Assistant and handles all automatio The switch will also fail gracefully when Home Assistant is not available to act as a dumb toggle switch. ### Standard plugs: sonoff_basic_01.yaml, sonoff_basic_02.yaml -These are Sonoff Basics, with plugs on either side. One is used to switch on a floor fan, and the other is being reserved possibly to control a bathroom vent fan. +These are [Sonoff Basics][esphome-sonoff-basic], with plugs on either side. One is used to switch on a floor fan, and the other is being reserved possibly to control a bathroom vent fan. ### Power monitoring ONLY plugs: sonoff_s31_01.yaml, sonoff_s31_02.yaml These are Sonoff S31 plugs are set to power on a boot, their physical "power" push buttons are disabled, and the virtual button hidden from Home Assistant. They are being used to monitor the power usage of a clothes washing machine and my wife's Glowforge laser cutter. With this data, I can create automations to alert us when the wash cycle or the laser cycle is complete. @@ -51,7 +57,6 @@ These are Sonoff POWs and Sonoff S31s. The code attempts to recreate their funct Ask on the [ESPHome #general channel on Discord][discord]. Use `#BrianHanifin` to tag me. - [commits-shield]: https://img.shields.io/github/commit-activity/m/brianhanifin/esphome-config.svg [commits]: https://github.com/brianhanifin/esphome-config/commits/master [github-last-commit]: https://img.shields.io/github/last-commit/BrianHanifin/esphome-config.svg?style=plasticr @@ -65,4 +70,5 @@ Ask on the [ESPHome #general channel on Discord][discord]. Use `#BrianHanifin` t [esphome-ble-hub]:https://esphome.io/components/esp32_ble_tracker.html +[esphome-sonoff4pro]:https://esphome.io/devices/sonoff_4ch.html [esphome-sonoff-basic]:https://esphome.io/devices/sonoff_basic.html diff --git a/common/substitutions/gpio/sonoffs31.yaml b/common/substitutions/gpio/sonoff.yaml similarity index 61% rename from common/substitutions/gpio/sonoffs31.yaml rename to common/substitutions/gpio/sonoff.yaml index 1a830cb..0d047d0 100644 --- a/common/substitutions/gpio/sonoffs31.yaml +++ b/common/substitutions/gpio/sonoff.yaml @@ -2,6 +2,3 @@ button_gpio: GPIO0 led_status_gpio: GPIO13 relay_gpio: GPIO12 - -# rx_gpio: GPIO3 -# tx_gpio: GPIO1 diff --git a/common/substitutions/gpio/sonoffpow.yaml b/common/substitutions/gpio/sonoffpow.yaml deleted file mode 100644 index 7835982..0000000 --- a/common/substitutions/gpio/sonoffpow.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -<<: !include sonoffs31.yaml diff --git a/common/substitutions/gpio/tuya_plug.yaml b/common/substitutions/gpio/tuya_plug.yaml index f73ae36..b383006 100644 --- a/common/substitutions/gpio/tuya_plug.yaml +++ b/common/substitutions/gpio/tuya_plug.yaml @@ -1,4 +1,5 @@ --- +# These brands share the same pins: Luntak, ZooZee. button_gpio: GPIO13 led_status_gpio: GPIO2 relay_gpio: GPIO15 diff --git a/common/templates/tuya_plug.yaml b/common/templates/plug.yaml similarity index 100% rename from common/templates/tuya_plug.yaml rename to common/templates/plug.yaml diff --git a/common/templates/sonoff_pow.yaml b/common/templates/sonoff_power_monitor.yaml similarity index 100% rename from common/templates/sonoff_pow.yaml rename to common/templates/sonoff_power_monitor.yaml diff --git a/common/templates/sonoff_s31_always_on.yaml b/common/templates/sonoff_power_monitor_always_on.yaml similarity index 100% rename from common/templates/sonoff_s31_always_on.yaml rename to common/templates/sonoff_power_monitor_always_on.yaml diff --git a/common/templates/sonoff_s31.yaml b/common/templates/sonoff_s31.yaml deleted file mode 100644 index 6d8aa48..0000000 --- a/common/templates/sonoff_s31.yaml +++ /dev/null @@ -1,28 +0,0 @@ ---- -esphome: - name: $id - platform: ESP8266 - board: esp01_1m - - <<: !include ../esphome/leds/status.yaml - -<<: !include ../wifi.yaml -<<: !include ../ota.yaml -<<: !include ../api.yaml - -<<: !include ../power_monitor_logger_uart.yaml - -binary_sensor: - <<: !include ../binary_sensors/power_button.yaml - -light: - <<: !include ../lights/status_led.yaml - -output: - <<: !include ../outputs/status_led.yaml - -sensor: - <<: !include ../sensors/power_monitor_cse7766.yaml - -switch: - <<: !include ../switches/relay.yaml diff --git a/dog_water.yaml b/dog_water.yaml deleted file mode 100755 index e77578f..0000000 --- a/dog_water.yaml +++ /dev/null @@ -1,47 +0,0 @@ ---- -# ESP8266 Dog Water Bowl Sensor -# -substitutions: - devicename: dog_water - devicename_upper: Dog Water Bowl - -esphome: - name: ${devicename} - platform: ESP8266 - board: esp8285 - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_pass - -# Enable Home Assistant API -api: - -ota: - safe_mode: True - -# Enable logging -logger: - -binary_sensor: - - platform: gpio - pin: - number: GPIO4 - #mode: INPUT_PULLUP - inverted: True - name: ${devicename_upper} - device_class: moisture - filters: - - delayed_on: 20ms - -sensor: - - platform: wifi_signal - name: ${devicename}_wifi_signal - update_interval: 30s - - - platform: uptime - name: ${devicename}_uptime - -text_sensor: - - platform: version - name: ${devicename}_esphome_version diff --git a/irrigation.yaml b/irrigation.yaml index 6b46548..5bf7319 100644 --- a/irrigation.yaml +++ b/irrigation.yaml @@ -23,7 +23,7 @@ esphome: platform: ESP8266 board: esp01_1m - <<: !include common/esphome/led/status_with_api.yaml + <<: !include common/esphome/leds/status_with_api.yaml <<: !include common/wifi.yaml <<: !include common/ota.yaml @@ -120,10 +120,10 @@ globals: # Common housekeeping components. output: - <<: !include common/output/status_led.yaml + <<: !include common/outputs/status_led.yaml light: - <<: !include common/light/status_led.yaml + <<: !include common/lights/status_led.yaml binary_sensor: - !include common/binary_sensors/status.yaml diff --git a/plug01.yaml b/plug01.yaml index a4b3af0..b0cd6c4 100755 --- a/plug01.yaml +++ b/plug01.yaml @@ -7,4 +7,4 @@ substitutions: <<: !include common/substitutions/gpio/tuya_plug.yaml -<<: !include common/templates/tuya_plug.yaml +<<: !include common/templates/plug.yaml diff --git a/plug02.yaml b/plug02.yaml index 4ddd374..3302e1a 100755 --- a/plug02.yaml +++ b/plug02.yaml @@ -7,4 +7,4 @@ substitutions: <<: !include common/substitutions/gpio/tuya_plug.yaml -<<: !include common/templates/tuya_plug.yaml +<<: !include common/templates/plug.yaml diff --git a/plug03.yaml b/plug03.yaml index 2266f22..cfc43fb 100755 --- a/plug03.yaml +++ b/plug03.yaml @@ -7,4 +7,4 @@ substitutions: <<: !include common/substitutions/gpio/tuya_plug.yaml -<<: !include common/templates/tuya_plug.yaml +<<: !include common/templates/plug.yaml diff --git a/plug04.yaml b/plug04.yaml index ddf82c4..d44d598 100644 --- a/plug04.yaml +++ b/plug04.yaml @@ -7,4 +7,4 @@ substitutions: <<: !include common/substitutions/gpio/tuya_plug.yaml -<<: !include common/templates/tuya_plug.yaml +<<: !include common/templates/plug.yaml diff --git a/plug05.yaml b/plug05.yaml index 57cb87d..501bfb5 100755 --- a/plug05.yaml +++ b/plug05.yaml @@ -7,4 +7,4 @@ substitutions: <<: !include common/substitutions/gpio/tuya_plug.yaml -<<: !include common/templates/tuya_plug.yaml +<<: !include common/templates/plug.yaml diff --git a/plug06.yaml b/plug06.yaml index 23347a8..66262b3 100755 --- a/plug06.yaml +++ b/plug06.yaml @@ -7,4 +7,4 @@ substitutions: <<: !include common/substitutions/gpio/tuya_plug.yaml -<<: !include common/templates/tuya_plug.yaml +<<: !include common/templates/plug.yaml diff --git a/plug07.yaml b/plug07.yaml index e51ccd5..7b54870 100755 --- a/plug07.yaml +++ b/plug07.yaml @@ -7,4 +7,4 @@ substitutions: <<: !include common/substitutions/gpio/tuya_plug.yaml -<<: !include common/templates/tuya_plug.yaml +<<: !include common/templates/plug.yaml diff --git a/sonoff_basic_01.yaml b/sonoff_basic_01.yaml index d249c15..89c5665 100755 --- a/sonoff_basic_01.yaml +++ b/sonoff_basic_01.yaml @@ -2,58 +2,9 @@ # Sonoff Basic Power Module # substitutions: - devicename: sonoff_basic_01 - upper_devicename: Sonoff Basic 01 + project: Sonoff Basic 01 + id: sonoff_basic_01 -esphome: - name: ${devicename} - platform: ESP8266 - board: esp01_1m - board_flash_mode: dout + <<: !include common/substitutions/gpio/sonoff.yaml -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_pass - -# Enable Home Assistant API -api: - -ota: - safe_mode: True - -binary_sensor: - - platform: gpio - pin: - number: GPIO0 - mode: INPUT_PULLUP - inverted: True - name: ${upper_devicename} Button - id: ${devicename}_button - on_press: - - switch.toggle: relay - # - platform: status - # name: ${upper_devicename} Status - # id: ${devicename}_status - -output: - # Register the green LED as a dimmable output .... - - platform: esp8266_pwm - id: green_led - pin: - number: GPIO13 - inverted: True - -light: - # ... and then make a light out of it. - - platform: monochromatic - name: ${upper_devicename} Green LED - id: ${devicename}_green_led - output: green_led - internal: true # hide from Home Assistant - -switch: - - platform: gpio - name: ${upper_devicename} - id: relay - pin: GPIO12 - restore_mode: ALWAYS_OFF +<<: !include common/templates/plug.yaml diff --git a/sonoff_basic_02.yaml b/sonoff_basic_02.yaml index f328bae..dbfff65 100755 --- a/sonoff_basic_02.yaml +++ b/sonoff_basic_02.yaml @@ -2,69 +2,9 @@ # Sonoff Basic Power Module # substitutions: - devicename: sonoff_basic_02 - upper_devicename: Sonoff Basic 02 + project: Sonoff Basic 02 + id: sonoff_basic_02 -esphome: - name: ${devicename} - platform: ESP8266 - board: esp01_1m - board_flash_mode: dout + <<: !include common/substitutions/gpio/sonoff.yaml -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_pass - - # Fallback Hotspot (requires "captive_portal:"). -# ap: -# ssid: ${devicename} -# password: "12345678" - -# captive_portal: - -# Enable Home Assistant API -api: - -ota: - safe_mode: True - -logger: - -binary_sensor: - ## DISABLED due to the button being broken. - # - platform: gpio - # pin: - # number: GPIO0 - # mode: INPUT_PULLUP - # inverted: True - # name: ${upper_devicename} Button - # id: ${devicename}_button - # on_press: - # - switch.toggle: relay - - # - platform: status - # name: ${upper_devicename} Status - # id: ${devicename}_status - -output: - # Register the green LED as a dimmable output .... - - platform: esp8266_pwm - id: green_led - pin: - number: GPIO13 - inverted: True - -light: - # ... and then make a light out of it. - - platform: monochromatic - name: ${upper_devicename} Green LED - id: ${devicename}_green_led - output: green_led - internal: true # hide from Home Assistant - -switch: - - platform: gpio - name: ${upper_devicename} - id: relay - pin: GPIO12 - restore_mode: ALWAYS_ON +<<: !include common/templates/plug.yaml diff --git a/sonoff_pow_01.yaml b/sonoff_pow_01.yaml index a946102..779e079 100755 --- a/sonoff_pow_01.yaml +++ b/sonoff_pow_01.yaml @@ -5,6 +5,6 @@ substitutions: project: Sonoff POW 01 id: sonoff_pow_01 - <<: !include common/substitutions/gpio/sonoffpow.yaml + <<: !include common/substitutions/gpio/sonoff.yaml -<<: !include common/templates/sonoff_pow.yaml +<<: !include common/templates/sonoff_power_monitor.yaml diff --git a/sonoff_pow_02.yaml b/sonoff_pow_02.yaml index a031dbf..a12623a 100755 --- a/sonoff_pow_02.yaml +++ b/sonoff_pow_02.yaml @@ -5,6 +5,6 @@ substitutions: project: Sonoff POW 02 id: sonoff_pow_02 - <<: !include common/substitutions/gpio/sonoffpow.yaml + <<: !include common/substitutions/gpio/sonoff.yaml -<<: !include common/templates/sonoff_pow.yaml +<<: !include common/templates/sonoff_power_monitor.yaml diff --git a/sonoff_s31_01.yaml b/sonoff_s31_01.yaml index fa33057..1a8a34d 100755 --- a/sonoff_s31_01.yaml +++ b/sonoff_s31_01.yaml @@ -5,6 +5,6 @@ substitutions: project: Sonoff S31 01 id: sonoff_s31_01 - <<: !include common/substitutions/gpio/sonoffs31.yaml + <<: !include common/substitutions/gpio/sonoff.yaml -<<: !include common/templates/sonoff_s31_always_on.yaml +<<: !include common/templates/sonoff_power_monitor_always_on.yaml diff --git a/sonoff_s31_02.yaml b/sonoff_s31_02.yaml index 0f02a96..8bf7d8d 100755 --- a/sonoff_s31_02.yaml +++ b/sonoff_s31_02.yaml @@ -5,6 +5,6 @@ substitutions: project: Sonoff S31 02 id: sonoff_s31_02 - <<: !include common/substitutions/gpio/sonoffs31.yaml + <<: !include common/substitutions/gpio/sonoff.yaml -<<: !include common/templates/sonoff_s31_always_on.yaml +<<: !include common/templates/sonoff_power_monitor_always_on.yaml diff --git a/sonoff_s31_03.yaml b/sonoff_s31_03.yaml index 9c21e9c..40c97cb 100755 --- a/sonoff_s31_03.yaml +++ b/sonoff_s31_03.yaml @@ -5,6 +5,6 @@ substitutions: project: Sonoff S31 03 id: sonoff_s31_03 - <<: !include common/substitutions/gpio/sonoffs31.yaml + <<: !include common/substitutions/gpio/sonoff.yaml -<<: !include common/templates/sonoff_s31.yaml +<<: !include common/templates/sonoff_power_monitor.yaml diff --git a/sonoff_s31_04.yaml b/sonoff_s31_04.yaml index 3aaf6ba..2101fd4 100755 --- a/sonoff_s31_04.yaml +++ b/sonoff_s31_04.yaml @@ -5,6 +5,6 @@ substitutions: project: Sonoff S31 04 id: sonoff_s31_04 - <<: !include common/substitutions/gpio/sonoffs31.yaml + <<: !include common/substitutions/gpio/sonoff.yaml -<<: !include common/templates/sonoff_s31.yaml +<<: !include common/templates/sonoff_power_monitor.yaml diff --git a/sonoff_s31_05.yaml b/sonoff_s31_05.yaml index 6e72bde..610b564 100755 --- a/sonoff_s31_05.yaml +++ b/sonoff_s31_05.yaml @@ -5,6 +5,6 @@ substitutions: project: Sonoff S31 05 id: sonoff_s31_05 - <<: !include common/substitutions/gpio/sonoffs31.yaml + <<: !include common/substitutions/gpio/sonoff.yaml -<<: !include common/templates/sonoff_s31.yaml +<<: !include common/templates/sonoff_power_monitor.yaml diff --git a/sonoff_s31_06.yaml b/sonoff_s31_06.yaml index 1eb5c95..ce1dddb 100755 --- a/sonoff_s31_06.yaml +++ b/sonoff_s31_06.yaml @@ -5,6 +5,6 @@ substitutions: project: Sonoff S31 06 id: sonoff_s31_06 - <<: !include common/substitutions/gpio/sonoffs31.yaml + <<: !include common/substitutions/gpio/sonoff.yaml -<<: !include common/templates/sonoff_s31.yaml +<<: !include common/templates/sonoff_power_monitor.yaml