esphome: name: sthome-ut1 friendly_name: sthome-ut1 esp32: board: esp32dev framework: type: arduino # Enable logging logger: # Enable Home Assistant API api: encryption: key: "0Ki4j7JX8Y1IkMGh1fBBu2Dg6DgrnUq8GEXKZvkzeSY=" ota: - platform: esphome password: "37f546590fcc15e1323d273540eb623a" 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 manual_ip: # For faster connection startup, set a static IP address # Set this to the IP of the ESP static_ip: 10.0.2.1 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: "sthome-ut1 Fallback Hotspot" password: "7SglIlgdkpAD" captive_portal: #preferences: # flash_write_interval: 30s #-25.711340, 28.118370 sun: latitude: -25.711340 longitude: 28.118370 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 #define OUTPUT_R4 19 switch: - platform: gpio pin: number: GPIO16 inverted: true id: relay1 name: "Floodlights Backyard" icon: "mdi:light-flood-down" restore_mode: RESTORE_DEFAULT_OFF on_turn_on: - delay: 600s - switch.turn_off: relay1 - platform: gpio pin: number: GPIO17 inverted: true id: relay2 name: "Relay 2" icon: "mdi:run-fast" restore_mode: RESTORE_DEFAULT_OFF on_turn_on: - delay: 1000ms - switch.turn_off: relay2 - platform: gpio pin: number: GPIO18 inverted: true id: relay3 name: "Relay 3" icon: "mdi:run-fast" restore_mode: RESTORE_DEFAULT_OFF on_turn_on: - delay: 1000ms - switch.turn_off: relay3 - platform: gpio pin: number: GPIO19 inverted: true id: relay4 name: "Alarm Zone 4" icon: "mdi:alarm-light-outline" restore_mode: RESTORE_DEFAULT_OFF on_turn_on: - if: condition: - sun.is_below_horizon: then: - switch.turn_on: relay1 - if: condition: - binary_sensor.is_on: floodlight_test then: - switch.turn_on: relay1 - delay: 30s - switch.turn_off: relay4 #define ANALOG_A1 33 #define ANALOG_A2 32 #define ANALOG_A3 35 #define ANALOG_A4 34 #define ANALOG_A5 39 #define ANALOG_A6 36 sensor: - platform: adc pin: 35 name: "Alarm Signal" id: alarm_signal update_interval: 500ms attenuation: 12db sampling_mode: avg filters: - lambda: if (x >= 3.11) { return x * 1.60256; } else if (x <= 0.15) { return 0; } else { return x * 1.51; } on_value: then: # switch on floodlights lambda: |- if (id(alarm_signal).state > 1.5) { id(relay1).turn_on(); } # - platform: adc # pin: 33 # name: "A1 Voltage" # update_interval: 1s # attenuation: 12db # filters: # # - multiply: 1.51515 # - lambda: # if (x >= 3.11) { # return x * 1.60256; # } else if (x <= 0.15) { # return 0; # } else { # return x * 1.51; # } # - platform: adc # pin: 32 # name: "A2 Voltage" # update_interval: 1s # attenuation: 12db # filters: # - lambda: # if (x >= 3.11) { # return x * 1.60256; # } else if (x <= 0.15) { # return 0; # } else { # return x * 1.51; # } # - platform: adc # pin: 34 # name: "A4 Voltage" # update_interval: 5s # attenuation: 12db # filters: # - lambda: # if (x >= 3.11) { # return x * 1.60256; # } else if (x <= 0.15) { # return 0; # } else { # return x * 1.51; # } # - platform: adc # pin: 39 # name: "A5 Voltage" # update_interval: 5s # attenuation: 12db # filters: # - lambda: # if (x >= 3.11) { # return x * 1.60256; # } else if (x <= 0.15) { # return 0; # } else { # return x * 1.51; # } # - platform: adc # pin: 36 # name: "A6 Voltage" # update_interval: 5s # attenuation: 12db # filters: # - lambda: # if (x >= 3.11) { # return x * 1.60256; # } else if (x <= 0.15) { # return 0; # } else { # return x * 1.51; # }