diff --git a/esphome/data/config/secrets.yaml b/esphome/data/config/secrets.yaml new file mode 100644 index 0000000..59e4ec2 --- /dev/null +++ b/esphome/data/config/secrets.yaml @@ -0,0 +1,16 @@ +# Your Wi-Fi SSID and password (default - used with new device setups) +# for multi network +wifi_ssid1: "sthome-2.4G1" +wifi_ssid2: "sthome-2.4G2" +wifi_ssid3: "sthome-2.4G3" +wifi_ssid4: "sthome-2.4G4" +wifi_ssid5: "sthome-2.4G5" +wifi_password1: "053d53f24e88d8618b618a2fa4c1d9" +wifi_password2: "053d53f24e88d8618b618a2fa4c1d9" +wifi_password3: "053d53f24e88d8618b618a2fa4c1d9" +wifi_password4: "053d53f24e88d8618b618a2fa4c1d9" +wifi_password5: "053d53f24e88d8618b618a2fa4c1d9" + +# Your Wi-Fi SSID and password +wifi_ssid: "sthome-2.4G1" +wifi_password: "053d53f24e88d8618b618a2fa4c1d9" diff --git a/esphome/data/config/sthome-ut1.yaml b/esphome/data/config/sthome-ut1.yaml index 032b91b..005a670 100644 --- a/esphome/data/config/sthome-ut1.yaml +++ b/esphome/data/config/sthome-ut1.yaml @@ -33,6 +33,8 @@ wifi: password: !secret wifi_password3 - ssid: !secret wifi_ssid4 password: !secret wifi_password4 + - ssid: !secret wifi_ssid5 + password: !secret wifi_password5 manual_ip: # For faster connection startup, set a static IP address # Set this to the IP of the ESP @@ -58,22 +60,6 @@ sun: time: - platform: homeassistant - -# define DIGITAL_D1 04 -binary_sensor: - - platform: gpio - # device_class: light - id: floodlight_test - pin: - number: GPIO04 - mode: - input: true - pullup: true - filters: - - delayed_off: 100ms - name: "Floodlights Test Mode" - icon: "mdi:lightbulb-on-outline" - #define OUTPUT_R1 16 #define OUTPUT_R2 17 #define OUTPUT_R3 18 @@ -87,8 +73,10 @@ switch: name: "Floodlights Backyard" icon: "mdi:light-flood-down" restore_mode: RESTORE_DEFAULT_OFF + # the backyard floodlight auto turns off in 4min 14 sec. So we need to switch relay off just before or at this time + # TODO: remove or extend auto turn off to >= 10min on_turn_on: - - delay: 600s + - delay: 250s - switch.turn_off: relay1 - platform: gpio @@ -137,6 +125,34 @@ switch: - delay: 30s - switch.turn_off: relay4 + +# define DIGITAL_D1 04 +binary_sensor: + - platform: gpio + # device_class: light + id: floodlight_test + pin: + number: GPIO04 + mode: + input: true + pullup: true + filters: + - delayed_off: 100ms + name: "Floodlights Test Mode" + icon: "mdi:lightbulb-on-outline" +# - platform: gpio +# # device_class: light +# id: alarm_signal +# pin: +# number: GPIO35 +# mode: +# input: true +# # pullup: true +# filters: +# - delayed_off: 50ms +# name: "Alarm Signal" +# icon: "mdi:alarm-light-outline" + #define ANALOG_A1 33 #define ANALOG_A2 32 #define ANALOG_A3 35 @@ -148,7 +164,7 @@ sensor: pin: 35 name: "Alarm Signal" id: alarm_signal - update_interval: 500ms + update_interval: 2000ms attenuation: 12db sampling_mode: avg filters: diff --git a/esphome/data/config/sthome-ut2.yaml b/esphome/data/config/sthome-ut2.yaml index 908d6a6..35f7a51 100644 --- a/esphome/data/config/sthome-ut2.yaml +++ b/esphome/data/config/sthome-ut2.yaml @@ -33,6 +33,8 @@ wifi: password: !secret wifi_password3 - ssid: !secret wifi_ssid4 password: !secret wifi_password4 + - ssid: !secret wifi_ssid5 + password: !secret wifi_password5 manual_ip: # For faster connection startup, set a static IP address # Set this to the IP of the ESP diff --git a/esphome/data/config/sthome-ut3.yaml b/esphome/data/config/sthome-ut3.yaml index d9b34dc..ccd642e 100644 --- a/esphome/data/config/sthome-ut3.yaml +++ b/esphome/data/config/sthome-ut3.yaml @@ -35,6 +35,8 @@ wifi: password: !secret wifi_password3 - ssid: !secret wifi_ssid4 password: !secret wifi_password4 + - ssid: !secret wifi_ssid5 + password: !secret wifi_password5 manual_ip: # For faster connection startup, set a static IP address # Set this to the IP of the ESP diff --git a/esphome/data/config/sthome-ut4.yaml b/esphome/data/config/sthome-ut4.yaml index 4c5e8ed..3814d47 100644 --- a/esphome/data/config/sthome-ut4.yaml +++ b/esphome/data/config/sthome-ut4.yaml @@ -35,6 +35,8 @@ wifi: password: !secret wifi_password3 - ssid: !secret wifi_ssid4 password: !secret wifi_password4 + - ssid: !secret wifi_ssid5 + password: !secret wifi_password5 manual_ip: # For faster connection startup, set a static IP address # Set this to the IP of the ESP @@ -49,4 +51,28 @@ wifi: ssid: "Sthome-Ut4 Fallback Hotspot" password: "FtGGLAU7OFPx" -captive_portal: \ No newline at end of file +captive_portal: + +switch: + - platform: gpio + pin: + number: GPIO10 + inverted: true + id: relay5 + name: "Relay 5" + icon: "mdi:lock-outline" + restore_mode: RESTORE_DEFAULT_OFF + #on_turn_on: + # - delay: 1000ms + # - switch.turn_off: relay5 + - platform: gpio + pin: + number: GPIO0 + inverted: true + id: relay6 + name: "Relay 6" + icon: "mdi:gate" + restore_mode: RESTORE_DEFAULT_OFF + on_turn_on: + - delay: 500ms + - switch.turn_off: relay6 \ No newline at end of file diff --git a/esphome/data/config/sthome-ut6.yaml b/esphome/data/config/sthome-ut6.yaml new file mode 100644 index 0000000..ecb7172 --- /dev/null +++ b/esphome/data/config/sthome-ut6.yaml @@ -0,0 +1,187 @@ +substitutions: + name: sthome-ut6 + friendly_name: "Sthome-Ut6" + +esphome: + name: "${name}" + friendly_name: "${friendly_name}" + +esp8266: + board: esp01_1m + +# Enable logging +logger: + +# Enable Home Assistant API +api: + encryption: + key: "K3yXQthpXVNknD4RCLZX66gglNgDEFtj3H0r85VLBNs=" + +ota: + - platform: esphome + password: "5956a60f6cf40cf4b6b172e23f236572" + +wifi: + #ssid: !secret wifi_ssid + #password: !secret wifi_password + # we will use local dns server for local dns resolution + domain: ".sthome.org" + networks: + - ssid: !secret wifi_ssid1 + password: !secret wifi_password1 + - ssid: !secret wifi_ssid2 + password: !secret wifi_password2 + - ssid: !secret wifi_ssid3 + password: !secret wifi_password3 + - ssid: !secret wifi_ssid4 + password: !secret wifi_password4 + - ssid: !secret wifi_ssid5 + password: !secret wifi_password5 + manual_ip: + # For faster connection startup, set a static IP address + # Set this to the IP of the ESP + static_ip: 10.0.2.6 + gateway: 10.0.0.2 + subnet: 255.255.240.0 + dns1: 10.0.0.1 + dns2: 10.0.0.2 + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "${friendly_name} Fallback Hotspot" + password: "HIjEc5P2BJhz" + +captive_portal: + +##################################################################################### + +# Minimal flash writes, once per day +preferences: + flash_write_interval: 10min + +# Sync time with Home Assistant +time: + - platform: homeassistant + id: homeassistant_time + +# Blink LED for status, and also expose to HA as switch +#light: +# - platform: status_led +# name: "${friendly_name} status light" +# id: blueled +# pin: +# number: GPIO2 +# inverted: yes +# restore_mode: RESTORE_DEFAULT_OFF +# +#script: +# - id: heartbeat +# mode: single +# then: +# - light.toggle: blueled +# - delay: 20 ms +# - light.toggle: blueled +# +# Heartbeat while connected to HA +#interval: +# - interval: 5s +# then: +# if: +# condition: +# api.connected: +# then: +# - script.execute: heartbeat +# + +switch: + # Switch to restart the ESP + - platform: restart + name: ${friendly_name} Restart + + - platform: gpio + pin: GPIO0 + name: "Relay 1" + inverted: false + id: relay1 + restore_mode: RESTORE_DEFAULT_OFF + on_turn_on: + - delay: 250ms + - switch.turn_off: relay1 + + - platform: gpio + pin: GPIO2 + name: "Relay 2" + inverted: false + id: relay2 + restore_mode: RESTORE_DEFAULT_OFF + on_turn_on: + - delay: 250ms + - switch.turn_off: relay2 + +text_sensor: + # Expose WiFi information as sensors + - platform: wifi_info + ip_address: + name: ${friendly_name} IP + mac_address: + name: ${friendly_name} Mac Address + + # human readable update text sensor from sensor:uptime + - platform: template + name: Uptime + id: uptime_human + icon: mdi:clock-start + +binary_sensor: +# - platform: gpio +# # Use your pins for something fun! +# pin: +# number: GPIO3 +# inverted: true +# # HW: pull to ground with 10k, tie high through pump NC switch +# id: pump_alarm +# name: Drain Pump Alarm +# device_class: problem + - platform: status + # Status platform provides a connectivity sensor + name: "${friendly_name} - Status" + device_class: connectivity + +sensor: + # Report wifi signal strength every 5 min if changed + - platform: wifi_signal + name: ${friendly_name} WiFi Signal + update_interval: 300s + filters: + - delta: 10% + # human readable uptime sensor output to the text sensor above + - platform: uptime + name: ${friendly_name} Uptime in Days + id: uptime_sensor_days + update_interval: 60s + on_raw_value: + then: + - text_sensor.template.publish: + id: uptime_human + state: !lambda |- + int seconds = round(id(uptime_sensor_days).raw_state); + int days = seconds / (24 * 3600); + seconds = seconds % (24 * 3600); + int hours = seconds / 3600; + seconds = seconds % 3600; + int minutes = seconds / 60; + seconds = seconds % 60; + return ( + (days ? String(days) + "d " : "") + + (hours ? String(hours) + "h " : "") + + (minutes ? String(minutes) + "m " : "") + + (String(seconds) + "s") + ).c_str(); + +# Pin assignments for ESP-01 +# https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/ +# 3v3 | | RX/GPIO3 - high at boot +# RST | | GPIO0 - pulled up, flash if low on boot +# EN | | GPIO2 - pulled up, blue led on if pulled down, must be high at boot +# TX | | GND +# ^ TX/GPIO1 - high at boot \ No newline at end of file