├── images └── aithinker_esp32cam.jpg ├── plug1.yaml ├── plug2.yaml ├── plug3.yaml ├── plug4.yaml ├── plug5.yaml ├── plug6.yaml ├── espcam.yaml ├── esp32_car.yaml ├── houselights.yaml ├── immersion.yaml ├── sonoffmini1.yaml ├── sonoffpow.yaml ├── IrBridge.yaml ├── kitchen.yaml ├── littlebed.yaml ├── livingroom.yaml ├── masterbed.yaml ├── templatefiles ├── secrets.yaml ├── common.yaml ├── common_static.yaml ├── ir.yaml ├── esp32.yaml ├── aithinker_esp32cam.yaml ├── roomsensor_dht11.yaml ├── roomsensor_esp32.yaml ├── sonoff_mini.yaml ├── roomsensor_bmp280.yaml ├── testsensor.yaml ├── sonoff_powr2.yaml ├── sonoff_powr1.yaml └── up111.yaml ├── .gitignore ├── stc15pwm.h ├── stc15component.h ├── README.md └── utility.yaml /images/aithinker_esp32cam.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matt2005/esphome_configs/HEAD/images/aithinker_esp32cam.jpg -------------------------------------------------------------------------------- /plug1.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: plug1 3 | upper_devicename: "Plug1" 4 | <<: !include templatefiles/up111.yaml 5 | -------------------------------------------------------------------------------- /plug2.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: plug2 3 | upper_devicename: "Plug2" 4 | <<: !include templatefiles/up111.yaml 5 | -------------------------------------------------------------------------------- /plug3.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: plug3 3 | upper_devicename: "Plug3" 4 | <<: !include templatefiles/up111.yaml 5 | -------------------------------------------------------------------------------- /plug4.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: plug4 3 | upper_devicename: "Plug4" 4 | <<: !include templatefiles/up111.yaml 5 | -------------------------------------------------------------------------------- /plug5.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: plug5 3 | upper_devicename: "Plug5" 4 | <<: !include templatefiles/up111.yaml 5 | -------------------------------------------------------------------------------- /plug6.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: plug6 3 | upper_devicename: "Plug6" 4 | <<: !include templatefiles/up111.yaml 5 | -------------------------------------------------------------------------------- /espcam.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: "espcam" 3 | upper_devicename: "ESPCAM" 4 | 5 | <<: !include templatefiles/aithinker_esp32cam.yaml 6 | -------------------------------------------------------------------------------- /esp32_car.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: esp32_car 3 | upper_devicename: "ESP32_CAR" 4 | device_ip: "192.168.1.217" 5 | 6 | <<: !include templatefiles/esp32.yaml -------------------------------------------------------------------------------- /houselights.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: houselights 3 | upper_devicename: "HouseLights" 4 | device_ip: "192.168.1.219" 5 | 6 | <<: !include templatefiles/sonoff_mini.yaml -------------------------------------------------------------------------------- /immersion.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: immersion 3 | upper_devicename: "Immersion" 4 | device_ip: "192.168.1.124" 5 | 6 | <<: !include templatefiles/sonoff_powr1.yaml 7 | -------------------------------------------------------------------------------- /sonoffmini1.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: sonoffmini1 3 | upper_devicename: "SonOff Mini 1" 4 | # device_ip: "192.168.1.219" 5 | 6 | <<: !include templatefiles/sonoff_mini.yaml -------------------------------------------------------------------------------- /sonoffpow.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: sonoffpow 3 | upper_devicename: "Sonoff POW" 4 | device_ip: "192.168.1.214" 5 | 6 | <<: !include templatefiles/sonoff_powr1.yaml 7 | -------------------------------------------------------------------------------- /IrBridge.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: irbridge 3 | upper_devicename: "IrBridge" 4 | board: nodemcuv2 5 | device_ip: "192.168.1.220" 6 | 7 | <<: !include templatefiles/ir.yaml 8 | -------------------------------------------------------------------------------- /kitchen.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: kitchen 3 | upper_devicename: "Kitchen" 4 | board: nodemcuv2 5 | device_ip: "192.168.1.215" 6 | 7 | <<: !include templatefiles/roomsensor_dht11.yaml 8 | -------------------------------------------------------------------------------- /littlebed.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: littlebed 3 | upper_devicename: "Little Bedroom" 4 | board: nodemcuv2 5 | device_ip: "192.168.1.212" 6 | <<: !include templatefiles/roomsensor_dht11.yaml 7 | -------------------------------------------------------------------------------- /livingroom.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: livingroom 3 | upper_devicename: "Livingroom" 4 | device_ip: "192.168.1.218" 5 | board: d1_mini 6 | 7 | <<: !include templatefiles/roomsensor_bmp280.yaml 8 | -------------------------------------------------------------------------------- /masterbed.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: masterbed 3 | upper_devicename: "Masterbed" 4 | board: nodemcuv2 5 | device_ip: "192.168.1.216" 6 | 7 | <<: !include templatefiles/roomsensor_dht11.yaml 8 | -------------------------------------------------------------------------------- /templatefiles/secrets.yaml: -------------------------------------------------------------------------------- 1 | ssid: "WIFISSID" 2 | ssid_password: "WIFIKEY" 3 | api_password: "Password" 4 | ota_password: "Password" 5 | ip_subnet: "255.255.255.0" 6 | ip_gateway: "192.168.1.1" 7 | ip_dns1: "192.168.1.2" 8 | ip_dns2: "192.168.1.1" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gitignore settings for ESPHome 2 | # This is an example and may include too much for your use-case. 3 | # You can modify this file to suit your needs. 4 | /.esphome/ 5 | **/.pioenvs/ 6 | **/.piolibdeps/ 7 | **/lib/ 8 | **/src/ 9 | **/platformio.ini 10 | /secrets.yaml 11 | **/*.disabled 12 | **/* 13 | templatefiles/secrets.yaml 14 | -------------------------------------------------------------------------------- /templatefiles/common.yaml: -------------------------------------------------------------------------------- 1 | wifi: 2 | ssid: !secret ssid 3 | password: !secret ssid_password 4 | domain: .home.local 5 | 6 | # Enable logging 7 | logger: 8 | 9 | # Enable Home Assistant API 10 | api: 11 | password: !secret api_password 12 | reboot_timeout: 0s 13 | 14 | ota: 15 | password: !secret ota_password 16 | 17 | time: 18 | - platform: homeassistant 19 | id: homeassistant_time 20 | -------------------------------------------------------------------------------- /templatefiles/common_static.yaml: -------------------------------------------------------------------------------- 1 | wifi: 2 | ssid: !secret ssid 3 | password: !secret ssid_password 4 | #domain: .home.local 5 | fast_connect: true 6 | manual_ip: 7 | static_ip: ${device_ip} 8 | gateway: !secret ip_gateway 9 | subnet: !secret ip_subnet 10 | dns1: !secret ip_dns1 11 | dns2: !secret ip_dns2 12 | # use_address: "192.168.1.211" 13 | 14 | # Enable debug 15 | debug: 16 | 17 | # Enable logging 18 | logger: 19 | level: debug 20 | 21 | # Enable Home Assistant API 22 | api: 23 | password: !secret api_password 24 | 25 | ota: 26 | password: !secret ota_password 27 | 28 | time: 29 | - platform: homeassistant 30 | id: homeassistant_time 31 | -------------------------------------------------------------------------------- /stc15pwm.h: -------------------------------------------------------------------------------- 1 | #include "esphome.h" 2 | using namespace esphome; 3 | 4 | class STC15FloatOutput : public Component, public UARTDevice, public output::FloatOutput { 5 | public: 6 | char pre; 7 | STC15FloatOutput(UARTComponent *parent, const char prefix) 8 | :UARTDevice(parent) 9 | { 10 | pre = prefix; 11 | } 12 | void setup() override { 13 | // This will be called by App.setup() 14 | //pinMode(5, OUTPUT); 15 | } 16 | 17 | void write_state(float state) override { 18 | unsigned int v = (unsigned int) (state * 255.0); 19 | char packet[8]; 20 | packet[0] = pre; 21 | sprintf(&packet[1],"%d", v); 22 | for (int i=0; i<4; i++) { 23 | write(packet[i]); 24 | } 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /templatefiles/ir.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP8266 4 | board: esp01_1m 5 | 6 | <<: !include common.yaml 7 | 8 | sensor: 9 | - platform: wifi_signal 10 | name: ${upper_devicename} WiFi Signal 11 | update_interval: 60s 12 | - platform: uptime 13 | name: ${upper_devicename} Uptime 14 | switch: 15 | - platform: restart 16 | name: ${upper_devicename} Restart 17 | text_sensor: 18 | - platform: version 19 | name: ${upper_devicename} Version 20 | api: 21 | services: 22 | - service: send_raw_command 23 | variables: 24 | command: int[] 25 | then: 26 | - remote_transmitter.transmit_raw: 27 | code: !lambda 'return command;' 28 | remote_transmitter: 29 | pin: GPIO14 30 | carrier_duty_percent: 50% 31 | remote_receiver: 32 | pin: GPIO5 33 | dump: all 34 | #// GPIO4 Blue Led -------------------------------------------------------------------------------- /stc15component.h: -------------------------------------------------------------------------------- 1 | #include "esphome.h" 2 | #include "esphome/log.h" 3 | 4 | using namespace esphome; 5 | 6 | class STC15Component: public UARTDevice, public PollingComponent { 7 | public: 8 | STC15Component(UARTComponent *parent, uint32_t update_interval = 60000) : UARTDevice(parent), PollingComponent(update_interval) 9 | { 10 | 11 | } 12 | sensor::Sensor *temperature = new sensor::Sensor(); 13 | sensor::Sensor *humidity = new sensor::Sensor(); 14 | 15 | void setup() override { 16 | // nothing to do here 17 | } 18 | 19 | void update() override { 20 | while (available()) { 21 | char c = read(); 22 | } 23 | 24 | static const char *TAG = "sensor.stc"; 25 | ESP_LOGCONFIG(TAG, "STC"); 26 | 27 | write('t'); 28 | float i = parseFloat(); 29 | temperature->publish_state(i); 30 | LOG_SENSOR(" ", "TEMP", this->temperature); 31 | 32 | write('h'); 33 | i = parseFloat(); 34 | humidity->publish_state(i); 35 | LOG_SENSOR(" ", "HUM", this->temperature); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /templatefiles/esp32.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP32 4 | board: nodemcu-32s 5 | 6 | #deep_sleep: 7 | # run_duration: 5s 8 | # sleep_duration: 60min 9 | 10 | <<: !include common_static.yaml 11 | 12 | sensor: 13 | - platform: wifi_signal 14 | name: ${upper_devicename} WiFi Signal 15 | id: ${devicename}_wifi_signal 16 | update_interval: 900s 17 | - platform: uptime 18 | name: ${upper_devicename} Uptime 19 | 20 | switch: 21 | - platform: restart 22 | name: ${upper_devicename} Restart 23 | 24 | text_sensor: 25 | - platform: version 26 | name: ${upper_devicename} Version 27 | - platform: template 28 | name: ${upper_devicename} MAC Address 29 | lambda: 'return {WiFi.macAddress().c_str()};' 30 | icon: mdi:fingerprint 31 | update_interval: 60s 32 | - platform: template 33 | name: ${upper_devicename} Wifi Strength 34 | id: ${devicename}_wifi_strength 35 | icon: "mdi:wifi" 36 | lambda: |- 37 | if (id(${devicename}_wifi_signal).state > -50 ) { 38 | return {"Excellent"}; 39 | } else if (id(${devicename}_wifi_signal).state > -60) { 40 | return {"Good"}; 41 | } else if (id(${devicename}_wifi_signal).state > -70) { 42 | return {"Fair"}; 43 | } else if (id(${devicename}_wifi_signal).state < -70) { 44 | return {"Weak"}; 45 | } else { 46 | return {"None"}; 47 | } 48 | update_interval: 900s 49 | -------------------------------------------------------------------------------- /templatefiles/aithinker_esp32cam.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP32 4 | board: esp-wrover-kit 5 | 6 | <<: !include common.yaml 7 | sensor: 8 | - platform: wifi_signal 9 | name: ${upper_devicename} WiFi Signal 10 | id: ${devicename}_wifi_signal 11 | update_interval: 900s 12 | - platform: uptime 13 | name: ${upper_devicename} Uptime 14 | 15 | switch: 16 | - platform: restart 17 | name: ${upper_devicename} Restart 18 | - platform: gpio 19 | name: ${upper_devicename} Flash 20 | pin: GPIO4 21 | 22 | text_sensor: 23 | - platform: version 24 | name: ${upper_devicename} Version 25 | - platform: template 26 | name: ${upper_devicename} MAC Address 27 | lambda: 'return {WiFi.macAddress().c_str()};' 28 | icon: mdi:fingerprint 29 | update_interval: 60s 30 | - platform: template 31 | name: ${upper_devicename} Wifi Strength 32 | id: ${devicename}_wifi_strength 33 | icon: "mdi:wifi" 34 | lambda: |- 35 | if (id(${devicename}_wifi_signal).state > -50 ) { 36 | return {"Excellent"}; 37 | } else if (id(${devicename}_wifi_signal).state > -60) { 38 | return {"Good"}; 39 | } else if (id(${devicename}_wifi_signal).state > -70) { 40 | return {"Fair"}; 41 | } else if (id(${devicename}_wifi_signal).state < -70) { 42 | return {"Weak"}; 43 | } else { 44 | return {"None"}; 45 | } 46 | update_interval: 900s 47 | 48 | esp32_camera: #ai-thinker 49 | name: $upper_devicename Camera 50 | external_clock: 51 | pin: GPIO0 52 | frequency: 20MHz 53 | i2c_pins: 54 | sda: GPIO26 55 | scl: GPIO27 56 | data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35] 57 | vsync_pin: GPIO25 58 | href_pin: GPIO23 59 | pixel_clock_pin: GPIO22 60 | power_down_pin: GPIO32 61 | vertical_flip: false 62 | horizontal_mirror: false 63 | # test_pattern: true 64 | -------------------------------------------------------------------------------- /templatefiles/roomsensor_dht11.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP8266 4 | board: ${board} 5 | 6 | <<: !include common_static.yaml 7 | 8 | sensor: 9 | - platform: wifi_signal 10 | name: ${upper_devicename} WiFi Signal 11 | id: ${devicename}_wifi_signal 12 | update_interval: 900s 13 | - platform: uptime 14 | name: ${upper_devicename} Uptime 15 | - platform: dht 16 | pin: D2 17 | model: DHT11 18 | update_interval: 5s 19 | temperature: 20 | name: "${upper_devicename} Temperature" 21 | accuracy_decimals: 2 22 | filters: 23 | - sliding_window_moving_average: 24 | window_size: 10 25 | send_every: 5 26 | send_first_at: 2 27 | humidity: 28 | name: "${upper_devicename} Humidity" 29 | filters: 30 | - sliding_window_moving_average: 31 | window_size: 10 32 | send_every: 5 33 | send_first_at: 2 34 | switch: 35 | - platform: restart 36 | name: ${upper_devicename} Restart 37 | 38 | text_sensor: 39 | - platform: version 40 | name: ${upper_devicename} Version 41 | - platform: template 42 | name: ${upper_devicename} MAC Address 43 | lambda: 'return {WiFi.macAddress().c_str()};' 44 | icon: mdi:fingerprint 45 | update_interval: 60s 46 | - platform: template 47 | name: ${upper_devicename} Wifi Strength 48 | id: ${devicename}_wifi_strength 49 | icon: "mdi:wifi" 50 | lambda: |- 51 | if (id(${devicename}_wifi_signal).state > -50 ) { 52 | return {"Excellent"}; 53 | } else if (id(${devicename}_wifi_signal).state > -60) { 54 | return {"Good"}; 55 | } else if (id(${devicename}_wifi_signal).state > -70) { 56 | return {"Fair"}; 57 | } else if (id(${devicename}_wifi_signal).state < -70) { 58 | return {"Weak"}; 59 | } else { 60 | return {"None"}; 61 | } 62 | update_interval: 900s 63 | -------------------------------------------------------------------------------- /templatefiles/roomsensor_esp32.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP32 4 | board: nodemcu-32s 5 | 6 | #deep_sleep: 7 | # run_duration: 5s 8 | # sleep_duration: 60min 9 | 10 | <<: !include common_static.yaml 11 | 12 | sensor: 13 | - platform: wifi_signal 14 | name: ${upper_devicename} WiFi Signal 15 | id: ${devicename}_wifi_signal 16 | update_interval: 900s 17 | - platform: uptime 18 | name: ${upper_devicename} Uptime 19 | - platform: dht 20 | pin: GPIO15 21 | model: DHT11 22 | update_interval: 5s 23 | temperature: 24 | name: "${upper_devicename} Temperature" 25 | accuracy_decimals: 2 26 | filters: 27 | - sliding_window_moving_average: 28 | window_size: 10 29 | send_every: 5 30 | send_first_at: 2 31 | humidity: 32 | name: "${upper_devicename} Humidity" 33 | filters: 34 | - sliding_window_moving_average: 35 | window_size: 10 36 | send_every: 5 37 | send_first_at: 2 38 | 39 | switch: 40 | - platform: restart 41 | name: ${upper_devicename} Restart 42 | 43 | text_sensor: 44 | - platform: version 45 | name: ${upper_devicename} Version 46 | - platform: template 47 | name: ${upper_devicename} MAC Address 48 | lambda: 'return {WiFi.macAddress().c_str()};' 49 | icon: mdi:fingerprint 50 | update_interval: 60s 51 | - platform: template 52 | name: ${upper_devicename} Wifi Strength 53 | id: ${devicename}_wifi_strength 54 | icon: "mdi:wifi" 55 | lambda: |- 56 | if (id(${devicename}_wifi_signal).state > -50 ) { 57 | return {"Excellent"}; 58 | } else if (id(${devicename}_wifi_signal).state > -60) { 59 | return {"Good"}; 60 | } else if (id(${devicename}_wifi_signal).state > -70) { 61 | return {"Fair"}; 62 | } else if (id(${devicename}_wifi_signal).state < -70) { 63 | return {"Weak"}; 64 | } else { 65 | return {"None"}; 66 | } 67 | update_interval: 900s 68 | -------------------------------------------------------------------------------- /templatefiles/sonoff_mini.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP8266 4 | board: esp8285 5 | 6 | <<: !include common_static.yaml 7 | 8 | binary_sensor: 9 | - platform: gpio 10 | pin: GPIO00 11 | id: reset 12 | internal: true 13 | filters: 14 | - invert: 15 | - delayed_off: 10ms 16 | on_press: 17 | - switch.toggle: fakebutton 18 | - platform: gpio 19 | pin: 20 | number: GPIO4 21 | mode: INPUT_PULLUP 22 | inverted: True 23 | name: ${upper_devicename} Button 24 | on_press: 25 | - switch.turn_on: fakebutton 26 | on_release: 27 | - switch.turn_off: fakebutton 28 | 29 | sensor: 30 | - platform: wifi_signal 31 | name: ${upper_devicename} WiFi Signal 32 | id: ${devicename}_wifi_signal 33 | update_interval: 900s 34 | - platform: uptime 35 | name: ${upper_devicename} Uptime 36 | switch: 37 | - platform: restart 38 | name: ${upper_devicename} Restart 39 | - platform: template 40 | name: ${upper_devicename} Relay 41 | optimistic: true 42 | id: fakebutton 43 | turn_on_action: 44 | - switch.turn_on: relay 45 | turn_off_action: 46 | - switch.turn_off: relay 47 | - platform: gpio 48 | id: relay 49 | pin: GPIO12 50 | 51 | text_sensor: 52 | - platform: version 53 | name: ${upper_devicename} Version 54 | - platform: template 55 | name: ${upper_devicename} MAC Address 56 | lambda: 'return {WiFi.macAddress().c_str()};' 57 | icon: mdi:fingerprint 58 | update_interval: 60s 59 | - platform: template 60 | name: ${upper_devicename} Wifi Strength 61 | id: ${devicename}_wifi_strength 62 | icon: "mdi:wifi" 63 | lambda: |- 64 | if (id(${devicename}_wifi_signal).state > -50 ) { 65 | return {"Excellent"}; 66 | } else if (id(${devicename}_wifi_signal).state > -60) { 67 | return {"Good"}; 68 | } else if (id(${devicename}_wifi_signal).state > -70) { 69 | return {"Fair"}; 70 | } else if (id(${devicename}_wifi_signal).state < -70) { 71 | return {"Weak"}; 72 | } else { 73 | return {"None"}; 74 | } 75 | update_interval: 900s 76 | 77 | status_led: 78 | pin: 79 | number: GPIO13 80 | inverted: yes -------------------------------------------------------------------------------- /templatefiles/roomsensor_bmp280.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP8266 4 | board: ${board} 5 | 6 | <<: !include common_static.yaml 7 | 8 | i2c: 9 | - id: bus_a 10 | scl: D2 11 | sda: D1 12 | scan: True 13 | 14 | sensor: 15 | - platform: wifi_signal 16 | name: ${upper_devicename} WiFi Signal 17 | id: ${devicename}_wifi_signal 18 | update_interval: 900s 19 | - platform: uptime 20 | name: ${upper_devicename} Uptime 21 | - platform: bmp280 22 | i2c_id: bus_a 23 | update_interval: 5s 24 | address: 0x76 25 | temperature: 26 | name: "${upper_devicename} Temperature" 27 | accuracy_decimals: 2 28 | filters: 29 | - sliding_window_moving_average: 30 | window_size: 10 31 | send_every: 5 32 | send_first_at: 2 33 | # humidity: 34 | # name: "${upper_devicename} Humidity" 35 | # filters: 36 | # - sliding_window_moving_average: 37 | # window_size: 10 38 | # send_every: 5 39 | # send_first_at: 2 40 | pressure: 41 | name: "${upper_devicename} Pressure" 42 | filters: 43 | - sliding_window_moving_average: 44 | window_size: 10 45 | send_every: 5 46 | send_first_at: 2 47 | 48 | switch: 49 | - platform: restart 50 | name: ${upper_devicename} Restart 51 | 52 | text_sensor: 53 | - platform: version 54 | name: ${upper_devicename} Version 55 | - platform: template 56 | name: ${upper_devicename} MAC Address 57 | lambda: 'return {WiFi.macAddress().c_str()};' 58 | icon: mdi:fingerprint 59 | update_interval: 60s 60 | - platform: template 61 | name: ${upper_devicename} Wifi Strength 62 | id: ${devicename}_wifi_strength 63 | icon: "mdi:wifi" 64 | lambda: |- 65 | if (id(${devicename}_wifi_signal).state > -50 ) { 66 | return {"Excellent"}; 67 | } else if (id(${devicename}_wifi_signal).state > -60) { 68 | return {"Good"}; 69 | } else if (id(${devicename}_wifi_signal).state > -70) { 70 | return {"Fair"}; 71 | } else if (id(${devicename}_wifi_signal).state < -70) { 72 | return {"Weak"}; 73 | } else { 74 | return {"None"}; 75 | } 76 | update_interval: 900s 77 | -------------------------------------------------------------------------------- /templatefiles/testsensor.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP8266 4 | board: ${board} 5 | 6 | <<: !include common_static.yaml 7 | 8 | i2c: 9 | - id: bus_a 10 | scl: D2 11 | sda: D1 12 | scan: True 13 | dallas: 14 | - pin: D3 15 | sensor: 16 | - platform: wifi_signal 17 | name: ${upper_devicename} WiFi Signal 18 | id: ${devicename}_wifi_signal 19 | update_interval: 900s 20 | - platform: uptime 21 | name: ${upper_devicename} Uptime 22 | - platform: bmp280 23 | i2c_id: bus_a 24 | update_interval: 5s 25 | address: 0x76 26 | temperature: 27 | name: "${upper_devicename} Temperature" 28 | accuracy_decimals: 2 29 | filters: 30 | - sliding_window_moving_average: 31 | window_size: 10 32 | send_every: 5 33 | send_first_at: 2 34 | # humidity: 35 | # name: "${upper_devicename} Humidity" 36 | # filters: 37 | # - sliding_window_moving_average: 38 | # window_size: 10 39 | # send_every: 5 40 | # send_first_at: 2 41 | pressure: 42 | name: "${upper_devicename} Pressure" 43 | filters: 44 | - sliding_window_moving_average: 45 | window_size: 10 46 | send_every: 5 47 | send_first_at: 2 48 | - platform: dallas 49 | address: 0x4400000627BE3C28 50 | name: "${upper_devicename} Temperature #2" 51 | 52 | switch: 53 | - platform: restart 54 | name: ${upper_devicename} Restart 55 | 56 | text_sensor: 57 | - platform: version 58 | name: ${upper_devicename} Version 59 | - platform: template 60 | name: ${upper_devicename} MAC Address 61 | lambda: 'return {WiFi.macAddress().c_str()};' 62 | icon: mdi:fingerprint 63 | update_interval: 60s 64 | - platform: template 65 | name: ${upper_devicename} Wifi Strength 66 | id: ${devicename}_wifi_strength 67 | icon: "mdi:wifi" 68 | lambda: |- 69 | if (id(${devicename}_wifi_signal).state > -50 ) { 70 | return {"Excellent"}; 71 | } else if (id(${devicename}_wifi_signal).state > -60) { 72 | return {"Good"}; 73 | } else if (id(${devicename}_wifi_signal).state > -70) { 74 | return {"Fair"}; 75 | } else if (id(${devicename}_wifi_signal).state < -70) { 76 | return {"Weak"}; 77 | } else { 78 | return {"None"}; 79 | } 80 | update_interval: 900s 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # my esphome configs 2 | 3 | ## Overview 4 | 5 | I'm using version 1.14.0-dev in a hassio. 6 | 7 | The configurations are modular. Each device will have a single yaml file, this file will use a device specific file from the templatefiles directory. 8 | 9 | The device specific file will then import the common settings from either 10 | 11 | - [common.yaml](templatefiles/common.yaml) (THIS USES DHCP) 12 | - [common_static.yaml](templatefiles/common_static.yaml) (THIS USES STATIC IP) 13 | 14 | The common files will pull the secrets from templatefiles/secrets.yaml 15 | 16 | ## Common features 17 | 18 | Each Device has the following standard sensors: 19 | 20 | - MAC address 21 | - Uptime 22 | - Version 23 | - Wifi Signal (in dB) 24 | - Wifi Strength (in english) 25 | 26 | Each Device also has the following switch: 27 | 28 | - Restart 29 | 30 | ## Devices 31 | 32 | - Room Sensor DHT11 33 | 34 | This is a NodeMcu with a DHT11 connected to Pin D2. 35 | The temperature and humidity values are averaged to reduce erroreous spikes in values. 36 | 37 | [Configuration file: templatefiles\roomsensor_dht11.yaml](templatefiles/roomsensor_dht11.yaml) 38 | 39 | - Room Sensor bmp280 40 | 41 | This is a Wemos-D1 mini with a hw-611 e/p (bmp280) connected D1/sda D2/scl. 42 | 43 | [Configuration file: templatefiles\roomsensor_bmp280.yaml](templatefiles/roomsensor_bmp280.yaml) 44 | 45 | - Room Sensor (esp32) 46 | 47 | This is a Nodemcu-esp32 with a DHT11 connected to GPIO15. 48 | The temperature and humidity values are averaged to reduce erroreous spikes in values. 49 | 50 | [Configuration file: templatefiles\roomsensor_esp32.yaml](templatefiles/roomsensor_esp32.yaml) 51 | 52 | - espcam32 53 | 54 | 55 | 56 | This is an AIThinker esp32cam board available from [AliExpress](http://s.click.aliexpress.com/e/bdKN2vBK) I have installed heatsinks on the esp32 chip, as I found that the camera would stop working after a few minutes/hours. 57 | 58 | The Flash is presented as a switch. 59 | 60 | [Configuration file: templatefiles\aithinker_esp32cam.yaml](templatefiles/aithinker_esp32cam.yaml) 61 | 62 | - SonOff POW R1 63 | 64 | This is a SonOff POW R1 65 | 66 | [Configuration file: templatefiles\sonoff_powr1.yaml](templatefiles/sonoff_powr1.yaml) 67 | 68 | - SonOff POW R2 69 | 70 | This is a SonOff POW R2 71 | 72 | [Configuration file: templatefiles\sonoff_powr2.yaml](templatefiles/sonoff_powr2.yaml) 73 | 78 | -------------------------------------------------------------------------------- /templatefiles/sonoff_powr2.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP8266 4 | board: esp01_1m 5 | board_flash_mode: dout 6 | 7 | #deep_sleep: 8 | # run_duration: 5s 9 | # sleep_duration: 60min 10 | 11 | uart: 12 | rx_pin: RX 13 | baud_rate: 4800 14 | 15 | <<: !include common_static.yaml 16 | 17 | binary_sensor: 18 | - platform: gpio 19 | pin: 20 | number: GPIO0 21 | mode: INPUT_PULLUP 22 | inverted: True 23 | name: ${upper_devicename} Button 24 | on_press: 25 | - switch.toggle: fakebutton 26 | - platform: template 27 | name: ${upper_devicename} Running 28 | filters: 29 | - delayed_off: 15s 30 | lambda: |- 31 | if (isnan(id(power).state)) { 32 | return {}; 33 | } else if (id(power).state > 4) { 34 | // Running 35 | return true; 36 | } else { 37 | // Not running 38 | return false; 39 | } 40 | 41 | sensor: 42 | - platform: wifi_signal 43 | name: ${upper_devicename} WiFi Signal 44 | id: ${devicename}_wifi_signal 45 | update_interval: 900s 46 | - platform: uptime 47 | name: ${upper_devicename} Uptime 48 | - platform: cse7766 49 | update_interval: 2s 50 | current: 51 | name: ${upper_devicename} Current 52 | voltage: 53 | name: ${upper_devicename} Voltage 54 | power: 55 | name: ${upper_devicename} Power 56 | id: power 57 | on_value_range: 58 | - above: 4.0 59 | then: 60 | - light.turn_on: led 61 | - below: 3.0 62 | then: 63 | - light.turn_off: led 64 | 65 | switch: 66 | - platform: restart 67 | name: ${upper_devicename} Restart 68 | - platform: template 69 | name: ${upper_devicename} Relay 70 | optimistic: true 71 | id: fakebutton 72 | turn_on_action: 73 | - switch.turn_on: relay 74 | - light.turn_on: led 75 | turn_off_action: 76 | - switch.turn_off: relay 77 | - light.turn_off: led 78 | - platform: gpio 79 | id: relay 80 | pin: GPIO12 81 | 82 | text_sensor: 83 | - platform: version 84 | name: ${upper_devicename} Version 85 | - platform: template 86 | name: ${upper_devicename} MAC Address 87 | lambda: 'return {WiFi.macAddress().c_str()};' 88 | icon: mdi:fingerprint 89 | update_interval: 60s 90 | - platform: template 91 | name: ${upper_devicename} Wifi Strength 92 | id: ${devicename}_wifi_strength 93 | icon: "mdi:wifi" 94 | lambda: |- 95 | if (id(${devicename}_wifi_signal).state > -50 ) { 96 | return {"Excellent"}; 97 | } else if (id(${devicename}_wifi_signal).state > -60) { 98 | return {"Good"}; 99 | } else if (id(${devicename}_wifi_signal).state > -70) { 100 | return {"Fair"}; 101 | } else if (id(${devicename}_wifi_signal).state < -70) { 102 | return {"Weak"}; 103 | } else { 104 | return {"None"}; 105 | } 106 | update_interval: 900s 107 | 108 | output: 109 | - platform: esp8266_pwm 110 | id: pow_blue_led 111 | pin: 112 | number: GPIO13 113 | inverted: True 114 | 115 | light: 116 | - platform: monochromatic 117 | name: ${upper_devicename} Blue LED 118 | output: pow_blue_led 119 | id: led 120 | -------------------------------------------------------------------------------- /templatefiles/sonoff_powr1.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP8266 4 | board: esp01_1m 5 | board_flash_mode: dout 6 | 7 | #deep_sleep: 8 | # run_duration: 5s 9 | # sleep_duration: 60min 10 | 11 | uart: 12 | rx_pin: RX 13 | baud_rate: 4800 14 | 15 | <<: !include common_static.yaml 16 | 17 | binary_sensor: 18 | - platform: gpio 19 | pin: 20 | number: GPIO0 21 | mode: INPUT_PULLUP 22 | inverted: True 23 | name: ${upper_devicename} Button 24 | on_press: 25 | - switch.toggle: fakebutton 26 | - platform: template 27 | name: ${upper_devicename} Running 28 | filters: 29 | - delayed_off: 15s 30 | lambda: |- 31 | if (isnan(id(power).state)) { 32 | return {}; 33 | } else if (id(power).state > 4) { 34 | // Running 35 | return true; 36 | } else { 37 | // Not running 38 | return false; 39 | } 40 | 41 | sensor: 42 | - platform: wifi_signal 43 | name: ${upper_devicename} WiFi Signal 44 | id: ${devicename}_wifi_signal 45 | update_interval: 900s 46 | - platform: uptime 47 | name: ${upper_devicename} Uptime 48 | - platform: hlw8012 49 | sel_pin: 5 50 | cf_pin: 14 51 | cf1_pin: 13 52 | update_interval: 2s 53 | current: 54 | name: ${upper_devicename} Current 55 | voltage: 56 | name: ${upper_devicename} Voltage 57 | power: 58 | name: ${upper_devicename} Power 59 | id: power 60 | on_value_range: 61 | - above: 4.0 62 | then: 63 | - light.turn_on: led 64 | - below: 3.0 65 | then: 66 | - light.turn_off: led 67 | - platform: total_daily_energy 68 | name: ${upper_devicename} Total Daily Energy 69 | power_id: power 70 | switch: 71 | - platform: restart 72 | name: ${upper_devicename} Restart 73 | - platform: template 74 | name: ${upper_devicename} Relay 75 | optimistic: true 76 | id: fakebutton 77 | turn_on_action: 78 | - switch.turn_on: relay 79 | - light.turn_on: led 80 | turn_off_action: 81 | - switch.turn_off: relay 82 | - light.turn_off: led 83 | - platform: gpio 84 | id: relay 85 | pin: GPIO12 86 | 87 | text_sensor: 88 | - platform: version 89 | name: ${upper_devicename} Version 90 | - platform: template 91 | name: ${upper_devicename} MAC Address 92 | lambda: 'return {WiFi.macAddress().c_str()};' 93 | icon: mdi:fingerprint 94 | update_interval: 60s 95 | - platform: template 96 | name: ${upper_devicename} Wifi Strength 97 | id: ${devicename}_wifi_strength 98 | icon: "mdi:wifi" 99 | lambda: |- 100 | if (id(${devicename}_wifi_signal).state > -50 ) { 101 | return {"Excellent"}; 102 | } else if (id(${devicename}_wifi_signal).state > -60) { 103 | return {"Good"}; 104 | } else if (id(${devicename}_wifi_signal).state > -70) { 105 | return {"Fair"}; 106 | } else if (id(${devicename}_wifi_signal).state < -70) { 107 | return {"Weak"}; 108 | } else { 109 | return {"None"}; 110 | } 111 | update_interval: 900s 112 | 113 | output: 114 | - platform: esp8266_pwm 115 | id: pow_blue_led 116 | pin: 117 | number: GPIO15 118 | inverted: True 119 | 120 | light: 121 | - platform: monochromatic 122 | name: ${upper_devicename} Blue LED 123 | output: pow_blue_led 124 | id: led 125 | -------------------------------------------------------------------------------- /utility.yaml: -------------------------------------------------------------------------------- 1 | substitutions: 2 | devicename: utility 3 | upper_devicename: "Utility" 4 | device_ip: "192.168.1.217" 5 | 6 | <<: !include templatefiles/esp32.yaml 7 | 8 | remote_receiver: 9 | pin: 10 | number: GPIO32 11 | inverted: False 12 | dump: 13 | #- rc5 14 | #- samsung 15 | #- lg 16 | #- nec 17 | #- panasonic 18 | #- jvc 19 | #- sony 20 | - rc_switch 21 | #- raw 22 | tolerance: 50% 23 | filter: 2us 24 | idle: 2ms 25 | binary_sensor: 26 | - platform: remote_receiver 27 | name: "Back Door Low Battery" 28 | id: backdoor_battery 29 | rc_switch_raw: 30 | protocol: 1 31 | code: '1' 32 | - platform: template 33 | id: backdoortamper 34 | name: "Back Door Tamper Sensor" 35 | filters: [] 36 | device_class: door 37 | - platform: remote_receiver 38 | name: "Back Door Tamper" 39 | id: backdoor_tamper 40 | internal: true 41 | rc_switch_raw: 42 | protocol: 1 43 | code: '101100001010101000000111' 44 | on_press: 45 | if: 46 | condition: 47 | - binary_sensor.is_off: backdoortamper 48 | then: 49 | - binary_sensor.template.publish: 50 | id: backdoortamper 51 | state: ON 52 | - platform: template 53 | id: backdoor 54 | name: "Back Door Sensor" 55 | filters: [] 56 | device_class: door 57 | - platform: remote_receiver 58 | name: "Back Door Open" 59 | id: backdoor_open 60 | internal: true 61 | rc_switch_raw: 62 | protocol: 1 63 | code: '101100001010101000001010' 64 | on_press: 65 | if: 66 | condition: 67 | - binary_sensor.is_off: backdoor 68 | then: 69 | - binary_sensor.template.publish: 70 | id: backdoor 71 | state: ON 72 | - platform: remote_receiver 73 | name: "Back Door Closed" 74 | id: backdoor_closed 75 | internal: true 76 | rc_switch_raw: 77 | protocol: 1 78 | code: '101100001010101000001110' 79 | on_press: 80 | if: 81 | condition: 82 | - binary_sensor.is_on: backdoor 83 | then: 84 | - binary_sensor.template.publish: 85 | id: backdoor 86 | state: OFF 87 | - platform: remote_receiver 88 | name: "Front Door Low Battery" 89 | id: frontdoor_battery 90 | rc_switch_raw: 91 | protocol: 1 92 | code: '1' 93 | - platform: template 94 | id: frontdoortamper 95 | name: "Front Door Tamper Sensor" 96 | filters: [] 97 | device_class: door 98 | - platform: remote_receiver 99 | name: "Front Door Tamper" 100 | id: frontdoor_tamper 101 | internal: true 102 | rc_switch_raw: 103 | protocol: 1 104 | code: '110110010111110100000111' 105 | on_press: 106 | if: 107 | condition: 108 | - binary_sensor.is_off: frontdoortamper 109 | then: 110 | - binary_sensor.template.publish: 111 | id: frontdoortamper 112 | state: ON 113 | - platform: template 114 | id: frontdoor 115 | name: "Front Door Sensor" 116 | filters: [] 117 | device_class: door 118 | - platform: remote_receiver 119 | name: "Front Door Open" 120 | id: frontdoor_open 121 | internal: true 122 | rc_switch_raw: 123 | protocol: 1 124 | code: '110110010111110100001010' 125 | on_press: 126 | if: 127 | condition: 128 | - binary_sensor.is_off: frontdoor 129 | then: 130 | - binary_sensor.template.publish: 131 | id: frontdoor 132 | state: ON 133 | - platform: remote_receiver 134 | name: "Front Door Closed" 135 | id: frontdoor_closed 136 | internal: true 137 | rc_switch_raw: 138 | protocol: 1 139 | code: '110110010111110100001110' 140 | on_press: 141 | if: 142 | condition: 143 | - binary_sensor.is_on: frontdoor 144 | then: 145 | - binary_sensor.template.publish: 146 | id: frontdoor 147 | state: OFF 148 | -------------------------------------------------------------------------------- /templatefiles/up111.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: $devicename 3 | platform: ESP8266 4 | board: esp01_1m 5 | 6 | <<: !include common.yaml 7 | 8 | binary_sensor: 9 | # Push Button 10 | - platform: gpio 11 | id: ${upper_devicename}_in_switch1 12 | internal: true 13 | pin: GPIO3 14 | name: " Switch 1" 15 | filters: 16 | - invert: 17 | on_click: 18 | min_length: 50ms 19 | max_length: 350ms 20 | then: 21 | - switch.toggle: ${upper_devicename}_out_relay1 22 | # Template Sensor - Tracks Relay, Switches LED to Match (Internal Only) 23 | - platform: template 24 | name: "${upper_devicename} Template 1" 25 | id: ${upper_devicename}_template1 26 | internal: true 27 | lambda: |- 28 | if (id(${upper_devicename}_out_relay1).state) { 29 | return true; 30 | } else { 31 | return false; 32 | } 33 | on_state: 34 | - if: 35 | condition: 36 | - binary_sensor.is_on: ${upper_devicename}_template1 37 | then: 38 | - switch.turn_on: ${upper_devicename}_out_led 39 | - if: 40 | condition: 41 | - binary_sensor.is_off: ${upper_devicename}_template1 42 | then: 43 | - switch.turn_off: ${upper_devicename}_out_led 44 | 45 | switch: 46 | # Restart Switch in HA 47 | - platform: restart 48 | name: "${upper_devicename} Restart" 49 | # Relay Output 50 | - platform: gpio 51 | pin: GPIO14 52 | id: ${upper_devicename}_out_relay1 53 | name: "${upper_devicename} Relay 1" 54 | restore_mode: ALWAYS_ON 55 | # Blue LED Output 56 | - platform: gpio 57 | pin: GPIO1 58 | internal: true 59 | id: ${upper_devicename}_out_led 60 | inverted: yes 61 | name: "${upper_devicename} Touch Status Led" 62 | - platform: gpio 63 | id: ${upper_devicename}_out_led_red 64 | name: "${upper_devicename} Touch Status Led Red" 65 | pin: GPIO13 66 | inverted: True 67 | restore_mode: ALWAYS_OFF 68 | 69 | sensor: 70 | - platform: hlw8012 71 | sel_pin: 72 | number: GPIO12 73 | inverted: True 74 | cf_pin: GPIO04 75 | cf1_pin: GPIO05 76 | # Higher value gives lower watt readout 77 | current_resistor: 0.0025 78 | # Lower value gives lower voltage readout 79 | voltage_divider: 880 80 | current: 81 | name: "${upper_devicename} energy_temp_Amperage" 82 | unit_of_measurement: A 83 | voltage: 84 | name: "${upper_devicename} energy_temp_Voltage" 85 | unit_of_measurement: V 86 | power: 87 | name: "${upper_devicename} energy_temp_Wattage" 88 | unit_of_measurement: W 89 | id: "energy_temp_Wattage" 90 | change_mode_every: 8 91 | update_interval: 10s 92 | - platform: total_daily_energy 93 | name: "${upper_devicename} energy_temp_Total Daily Energy" 94 | power_id: "energy_temp_Wattage" 95 | filters: 96 | # Multiplication factor from W to kW is 0.001 97 | - multiply: 0.001 98 | unit_of_measurement: kWh 99 | - platform: wifi_signal 100 | name: ${upper_devicename} WiFi Signal 101 | id: ${devicename}_wifi_signal 102 | update_interval: 900s 103 | - platform: uptime 104 | name: ${upper_devicename} Uptime 105 | 106 | text_sensor: 107 | - platform: version 108 | name: ${upper_devicename} Version 109 | - platform: template 110 | name: ${upper_devicename} MAC Address 111 | lambda: 'return {WiFi.macAddress().c_str()};' 112 | icon: mdi:fingerprint 113 | update_interval: 60s 114 | - platform: template 115 | name: ${upper_devicename} Wifi Strength 116 | id: ${devicename}_wifi_strength 117 | icon: "mdi:wifi" 118 | lambda: |- 119 | if (id(${devicename}_wifi_signal).state > -50 ) { 120 | return {"Excellent"}; 121 | } else if (id(${devicename}_wifi_signal).state > -60) { 122 | return {"Good"}; 123 | } else if (id(${devicename}_wifi_signal).state > -70) { 124 | return {"Fair"}; 125 | } else if (id(${devicename}_wifi_signal).state < -70) { 126 | return {"Weak"}; 127 | } else { 128 | return {"None"}; 129 | } 130 | update_interval: 900s 131 | 132 | status_led: 133 | pin: 134 | number: GPIO13 135 | inverted: yes --------------------------------------------------------------------------------