diff --git a/bathroom-lightswitch.yaml b/bathroom-lightswitch.yaml new file mode 100644 index 0000000..dc155cc --- /dev/null +++ b/bathroom-lightswitch.yaml @@ -0,0 +1,11 @@ +substitutions: + hostname: bathroom-switch + friendly_name: Bathroom Switch + touchpad2_action: sonoff_t3_toggle_relay_1_and_3 + + +packages: + device: !include devices/sonoff-t3.yaml + +wifi: + use_address: 192.168.10.10 diff --git a/bedroom-atom-echo.yaml b/bedroom-atom-echo.yaml new file mode 100644 index 0000000..52b5556 --- /dev/null +++ b/bedroom-atom-echo.yaml @@ -0,0 +1,62 @@ +substitutions: + hostname: bedroom-atom-echo + friendly_name: Bedroom Speaker + +packages: + base: !include common/base.yaml + sensors: !include common/basicSensors.yaml + +esphome: + name: ${hostname} + build_path: ./build/${hostname} + friendly_name: ${friendly_name} + +wifi: + use_address: 192.168.10.34 + +esp32: + board: m5stack-atom + +improv_serial: + +i2s_audio: + i2s_lrclk_pin: GPIO33 + i2s_bclk_pin: GPIO19 + +speaker: + - platform: i2s_audio + id: echo_speaker + i2s_dout_pin: GPIO22 + dac_type: external + mode: mono + +media_player: + - platform: i2s_audio + id: echo_media + name: None + dac_type: external + i2s_dout_pin: GPIO22 + +binary_sensor: + - platform: gpio + pin: + number: GPIO39 + inverted: true + name: Button + id: echo_button + +light: + - platform: esp32_rmt_led_strip + id: led + name: light + entity_category: config + pin: GPIO27 + default_transition_length: 0s + chipset: SK6812 + num_leds: 1 + rgb_order: grb + rmt_channel: 0 + effects: + - pulse: + transition_length: 250ms + update_interval: 250ms diff --git a/bedroom-bluetooth.yaml b/bedroom-bluetooth.yaml new file mode 100644 index 0000000..d1e22ee --- /dev/null +++ b/bedroom-bluetooth.yaml @@ -0,0 +1,11 @@ +substitutions: + hostname: bedroom-bluetooth + friendly_name: Bedroom Bluetooth + +wifi: + use_address: 192.168.10.27 + +packages: + device: !include devices/nodemcu.yaml + bt: !include common/bluetoothProxy.yaml + diff --git a/bedroom-lamp.yaml b/bedroom-lamp.yaml new file mode 100644 index 0000000..3720c0e --- /dev/null +++ b/bedroom-lamp.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: bedroom-lamp + friendly_name: Bedroom Lamp + +wifi: + use_address: 192.168.10.12 + +packages: + device: !include devices/sonoff-basic.yaml + diff --git a/bedroom-lightswitch.yaml b/bedroom-lightswitch.yaml new file mode 100644 index 0000000..bb4d7da --- /dev/null +++ b/bedroom-lightswitch.yaml @@ -0,0 +1,18 @@ +substitutions: + hostname: bedroom-switch + friendly_name: Bedroom Switch + touchpad1_action: toggle_bedroom_lamp + +wifi: + use_address: 192.168.10.3 + +packages: + device: !include devices/sonoff-t3.yaml + +script: + - id: toggle_bedroom_lamp + then: + - homeassistant.service: + service: homeassistant.toggle + data: + entity_id: "switch.bedroom_lamp_relay" diff --git a/build/bedroom-atom-echo/media/alarm.mp3 b/build/bedroom-atom-echo/media/alarm.mp3 new file mode 100644 index 0000000..c3da4f5 Binary files /dev/null and b/build/bedroom-atom-echo/media/alarm.mp3 differ diff --git a/cloakroom-lightswitch.yaml b/cloakroom-lightswitch.yaml new file mode 100644 index 0000000..80e318f --- /dev/null +++ b/cloakroom-lightswitch.yaml @@ -0,0 +1,19 @@ +substitutions: + hostname: cloakroom-switch + friendly_name: Cloakroom Switch + touchpad1_action: toggle_hall_light + + +packages: + device: !include devices/sonoff-t3.yaml + +wifi: + use_address: 192.168.10.16 + +script: + - id: toggle_hall_light + then: + - homeassistant.service: + service: homeassistant.toggle + data: + entity_id: "switch.front_door_switch_relay_2" diff --git a/common/base.yaml b/common/base.yaml new file mode 100644 index 0000000..7719031 --- /dev/null +++ b/common/base.yaml @@ -0,0 +1,19 @@ +wifi: + ssid: !secret WIFI_SSID + password: !secret WIFI_PASSWORD + fast_connect: true + reboot_timeout: 300s + ap: + ssid: ${friendly_name} Hotspot + +logger: + level: DEBUG + +api: + reboot_timeout: 15min + +ota: + +time: + - platform: homeassistant + timezone: Europe/London diff --git a/common/basicSensors.yaml b/common/basicSensors.yaml new file mode 100644 index 0000000..cb9ad90 --- /dev/null +++ b/common/basicSensors.yaml @@ -0,0 +1,42 @@ +binary_sensor: + - platform: status + name: ${friendly_name} Status + id: device_status + +sensor: + - platform: wifi_signal + name: ${friendly_name} WiFi Signal Strength + id: device_wifi_signal + update_interval: 15s + + - platform: uptime + name: ${friendly_name} Uptime + id: device_uptime + update_interval: 15s + +text_sensor: + - platform: version + name: ${friendly_name} ESPHome Version + id: esphome_version + + - platform: wifi_info + ip_address: + name: ${friendly_name} IP Address + id: ip_address + + ssid: + name: ${friendly_name} SSID + id: ssid + + bssid: + name: ${friendly_name} BSSID + id: bssid + + mac_address: + name: ${friendly_name} MAC Address + id: mac_address + +switch: + - platform: restart + name: ${friendly_name} Restart + id: device_restart diff --git a/common/bluetoothProxy.yaml b/common/bluetoothProxy.yaml new file mode 100644 index 0000000..3de47d8 --- /dev/null +++ b/common/bluetoothProxy.yaml @@ -0,0 +1,12 @@ +esp32: + framework: + type: esp-idf + +esp32_ble_tracker: + scan_parameters: + interval: 1100ms + window: 1100ms + active: true + +bluetooth_proxy: + active: true diff --git a/common/lightEffects.yaml b/common/lightEffects.yaml new file mode 100644 index 0000000..af58555 --- /dev/null +++ b/common/lightEffects.yaml @@ -0,0 +1,67 @@ +- lambda: + name: RGB Breathing + update_interval: 16s #Finetune to your liking with the transition lenght below + lambda: |- + #define Color1 1.0, 0.0, 0.0 //These are the colors defined, feel free to change or extend the list + #define Color2 1.0, 0.5, 0.0 //if you extend the list, dont forget to add them in the switch loop below + #define Color3 1.0, 1.0, 0.0 //and remember to adjust the reset counter at the bottom + #define Color4 0.5, 1.0, 0.0 + #define Color5 0.0, 1.0, 0.0 + #define Color6 0.0, 1.0, 0.5 + #define Color7 0.0, 1.0, 1.0 + #define Color8 0.0, 0.5, 1.0 + #define Color9 0.0, 0.0, 1.0 + #define Color10 0.5, 0.0, 1.0 + #define Color11 0.5, 0.0, 1.0 + #define Color12 1.0, 0.0, 0.5 + static int state = 0; + static int color = 1; + auto call = id(light1).turn_on(); + call.set_transition_length(15000); + if (state == 0) + { + call.set_brightness(0.01); + + } + else if (state == 1) + { + switch(color) + { + case 1: call.set_rgb(Color1); + break; + case 2: call.set_rgb(Color2); + break; + case 3: call.set_rgb(Color3); + break; + case 4: call.set_rgb(Color4); + break; + case 5: call.set_rgb(Color5); + break; + case 6: call.set_rgb(Color6); + break; + case 7: call.set_rgb(Color7); + break; + case 8: call.set_rgb(Color8); + break; + case 9: call.set_rgb(Color9); + break; + case 10: call.set_rgb(Color10); + break; + case 11: call.set_rgb(Color11); + break; + case 12: call.set_rgb(Color12); + break; + } + call.set_brightness(1.0); + } + + state ++; + if (state == 2){ + state = 0; + } + color++; + if(color == 7) + { + color = 1; + } + call.perform(); diff --git a/devices/athom-bulb.yaml b/devices/athom-bulb.yaml new file mode 100644 index 0000000..7b9f759 --- /dev/null +++ b/devices/athom-bulb.yaml @@ -0,0 +1,59 @@ +substitutions: + light_restore_mode: RESTORE_DEFAULT_ON + color_interlock: 'true' + +esphome: + board: esp8285 + platform: ESP8266 + name: ${hostname} + build_path: ./build/${hostname} + #on_boot: + # then: + # - script.execute: fast_boot_script + +packages: + base: !include ../common/base.yaml + basicSensors: !include ../common/basicSensors.yaml + +output: + - platform: esp8266_pwm + id: red_output + pin: GPIO4 + min_power: 0.000499 + max_power: 1 + - platform: esp8266_pwm + id: green_output + pin: GPIO12 + min_power: 0.000499 + max_power: 1 + - platform: esp8266_pwm + id: blue_output + pin: GPIO14 + min_power: 0.000499 + max_power: 1 + - platform: esp8266_pwm + id: warm_white_output + pin: GPIO13 + min_power: 0.000499 + max_power: 1 + - platform: esp8266_pwm + id: white_output + pin: GPIO5 + min_power: 0.000499 + max_power: 1 + + +light: + - platform: rgbww + id: light1 + name: "${friendly_name} Bulb" + restore_mode: ${light_restore_mode} + red: red_output + green: green_output + blue: blue_output + warm_white: warm_white_output + cold_white: white_output + cold_white_color_temperature: 6000 K + warm_white_color_temperature: 3000 K + color_interlock: ${color_interlock} + effects: !include ../common/lightEffects.yaml diff --git a/devices/localbytes-plug.yaml b/devices/localbytes-plug.yaml new file mode 100644 index 0000000..fce06bf --- /dev/null +++ b/devices/localbytes-plug.yaml @@ -0,0 +1,310 @@ +# Largely based off this: +#https://github.com/JamesSwift/localbytes-plug-pm/blob/main/localbytes-plug-pm.yaml +substitutions: + # Icon + main_icon: "power-socket-uk" + default_state: "RESTORE_DEFAULT_OFF" + +esphome: + name: ${hostname} + build_path: ./build/${hostname} + friendly_name: ${friendly_name} + +wifi: + output_power: 18db + power_save_mode: light + +esp8266: + board: esp01_1m + restore_from_flash: true + +packages: + base: !include ../common/base.yaml + basicSensors: !include ../common/basicSensors.yaml + +globals: + - id: voltage_multiply + type: float + restore_value: true + initial_value: "0.3" + + - id: power_multiply + type: float + restore_value: true + initial_value: "0.133" + + - id: current_multiply + type: float + restore_value: true + initial_value: "0.805" + +api: + services: + - service: calibrate_voltage + variables: + actual_value: float + then: + - lambda: |- + id(voltage_multiply) = actual_value / id(voltage).raw_state; + - number.set: + id: voltage_factor + value: !lambda "return id(voltage_multiply);" + + - service: calibrate_power + variables: + actual_value: float + then: + - lambda: |- + id(power_multiply) = actual_value / id(power).raw_state; + - number.set: + id: power_factor + value: !lambda "return id(power_multiply);" + + - service: calibrate_current + variables: + actual_value: float + then: + - lambda: |- + id(current_multiply) = actual_value / id(current).raw_state; + - number.set: + id: current_factor + value: !lambda "return id(current_multiply);" + +sensor: + # Power Monitoring + - platform: hlw8012 + sel_pin: + number: GPIO12 + inverted: true + cf_pin: GPIO4 + cf1_pin: GPIO5 + change_mode_every: 3 + update_interval: 6s + + voltage: + name: "Voltage" + id: voltage + unit_of_measurement: V + accuracy_decimals: 1 + filters: + - lambda: return x * id(voltage_multiply); + + power: + name: "Power" + id: power + unit_of_measurement: W + accuracy_decimals: 0 + filters: + - lambda: return x * id(power_multiply); + + current: + name: "Current" + id: current + unit_of_measurement: A + accuracy_decimals: 3 + filters: + - lambda: return x * id(current_multiply); + + # Total daily energy sensor + - platform: total_daily_energy + name: "Daily Energy" + power_id: power + filters: + # Multiplication factor from W to kW is 0.001 + - multiply: 0.001 + unit_of_measurement: kWh + + +# Make calibration factor data readable/setable from home assistant +number: + - platform: template + name: "Voltage Calibration Factor" + id: voltage_factor + icon: "mdi:sine-wave" + min_value: 0 + max_value: 10 + step: 0.001 + entity_category: diagnostic + mode: box + lambda: |- + return id(voltage_multiply); + set_action: + lambda: |- + id(voltage_multiply) = x; + + - platform: template + name: "Power Calibration Factor" + id: power_factor + icon: "mdi:flash" + min_value: 0 + max_value: 10 + step: 0.001 + entity_category: diagnostic + mode: box + lambda: |- + return id(power_multiply); + set_action: + lambda: |- + id(power_multiply) = x; + + - platform: template + name: "Current Calibration Factor" + id: current_factor + icon: "mdi:current-ac" + min_value: 0 + max_value: 10 + step: 0.001 + entity_category: diagnostic + mode: box + lambda: |- + return id(current_multiply); + set_action: + lambda: |- + id(current_multiply) = x; + +# Relay State LED +output: + - platform: esp8266_pwm + id: state_led + pin: + number: GPIO13 + inverted: true + +light: + - platform: binary + output: state_led + id: led + +binary_sensor: + # Push Button (Toggles Relay When Pressed) + - platform: gpio + pin: + number: GPIO3 + mode: INPUT_PULLUP + inverted: true + name: "Button" + on_click: + + - max_length: 1s + then: + if: + condition: + switch.is_off: disable_button + then: + switch.toggle: relay + + - min_length: 1.5s + max_length: 5s + then: + switch.toggle: disable_led + + - min_length: 8s + max_length: 12s + then: + switch.toggle: disable_button + + +switch: + # Relay (As Switch) + - platform: gpio + name: "" + icon: "mdi:${main_icon}" + pin: GPIO14 + id: relay + restore_mode: "${default_state}" + on_turn_on: + if: + condition: + switch.is_off: disable_led + then: + light.turn_on: + id: led + on_turn_off: + - light.turn_off: + id: led + + - platform: template + name: "Disable LED" + id: disable_led + icon: "mdi:led-variant-off" + restore_mode: "${default_state}" + optimistic: true + on_turn_on: + #Flash twice + - light.turn_off: led + - delay: 0.1s + - light.turn_on: led + - delay: 0.1s + - light.turn_off: led + - delay: 0.1s + - light.turn_on: led + - delay: 0.1s + #Final state + - light.turn_off: led + on_turn_off: + #Flash twice + - light.turn_on: led + - delay: 0.1s + - light.turn_off: led + - delay: 0.1s + - light.turn_on: led + - delay: 0.1s + - light.turn_off: led + - delay: 0.7s + #Final state + - if: + condition: + switch.is_on: relay + then: + light.turn_on: led + + + + - platform: template + name: "Disable Button" + id: disable_button + icon: "mdi:toggle-switch-off-outline" + restore_mode: "${default_state}" + optimistic: true + on_turn_on: + #Flash thrice + - light.turn_off: led + - delay: 0.15s + - light.turn_on: led + - delay: 0.15s + - light.turn_off: led + - delay: 0.15s + - light.turn_on: led + - delay: 0.15s + - light.turn_off: led + - delay: 0.15s + - light.turn_on: led + - delay: 0.15s + #Final state + - if: + condition: + switch.is_off: relay + then: + light.turn_off: led + on_turn_off: + #Flash thrice + - light.turn_on: led + - delay: 0.15s + - light.turn_off: led + - delay: 0.15s + - light.turn_on: led + - delay: 0.15s + - light.turn_off: led + - delay: 0.15s + - light.turn_on: led + - delay: 0.15s + - light.turn_off: led + - delay: 0.7s + #Final state + - if: + condition: + switch.is_on: relay + then: + light.turn_on: led + + diff --git a/devices/nodemcu.yaml b/devices/nodemcu.yaml new file mode 100644 index 0000000..3a96572 --- /dev/null +++ b/devices/nodemcu.yaml @@ -0,0 +1,13 @@ +substitutions: + +esphome: + name: ${hostname} + build_path: ./build/${hostname} + friendly_name: ${friendly_name} + +esp32: + board: nodemcu-32s + +packages: + base: !include ../common/base.yaml + basicSensors: !include ../common/basicSensors.yaml diff --git a/devices/sonoff-basic.yaml b/devices/sonoff-basic.yaml new file mode 100644 index 0000000..2d2823f --- /dev/null +++ b/devices/sonoff-basic.yaml @@ -0,0 +1,47 @@ +substitutions: + button_action: sonoff_button_toggle_relay + relay_on_action: nullScript + relay_off_action: nullScript + +esphome: + board: esp8285 + platform: ESP8266 + name: ${hostname} + build_path: ./build/${hostname} + +packages: + base: !include ../common/base.yaml + basicSensors: !include ../common/basicSensors.yaml + +switch: + - platform: gpio + name: "${friendly_name} Relay" + id: relay + pin: GPIO12 + restore_mode: RESTORE_DEFAULT_OFF + on_turn_on: + then: + - script.execute: "${relay_on_action}" + on_turn_off: + then: + - script.execute: "${relay_off_action}" + +binary_sensor: + - platform: gpio + pin: + number: GPIO0 + mode: INPUT_PULLUP + inverted: True + name: "${friendly_name} Button" + on_press: + then: + - script.execute: "${button_action}" + + +script: + - id: sonoff_button_toggle_relay + then: + - switch.toggle: relay + - id: nullScript + then: + diff --git a/devices/sonoff-t3.yaml b/devices/sonoff-t3.yaml new file mode 100644 index 0000000..61a65ef --- /dev/null +++ b/devices/sonoff-t3.yaml @@ -0,0 +1,95 @@ +substitutions: + touchpad1_action: sonoff_t3_toggle_relay_1 + touchpad2_action: sonoff_t3_toggle_relay_2 + touchpad3_action: sonoff_t3_toggle_relay_3 + +esphome: + board: esp01_1m + platform: ESP8266 + name: ${hostname} + build_path: ./build/${hostname} + +packages: + base: !include ../common/base.yaml + basicSensors: !include ../common/basicSensors.yaml + +output: + - platform: esp8266_pwm + id: blue_led + pin: GPIO13 + inverted: True + +switch: + - platform: gpio + name: "${friendly_name} Relay 1" + id: relay_1 + pin: GPIO12 + restore_mode: RESTORE_DEFAULT_OFF + - platform: gpio + name: "${friendly_name} Relay 2" + id: relay_2 + pin: GPIO5 + restore_mode: RESTORE_DEFAULT_OFF + - platform: gpio + name: "${friendly_name} Relay 3" + id: relay_3 + pin: GPIO4 + restore_mode: RESTORE_DEFAULT_OFF + +binary_sensor: + - platform: gpio + pin: + number: GPIO0 + mode: INPUT_PULLUP + inverted: True + name: "${friendly_name} Touchpad 1" + on_press: + then: + - output.turn_on: blue_led + - script.execute: "${touchpad1_action}" + on_release: + then: + - output.turn_off: blue_led + + - platform: gpio + pin: + number: GPIO9 + mode: INPUT_PULLUP + inverted: True + name: "${friendly_name} Touchpad 2" + on_press: + then: + - output.turn_on: blue_led + - script.execute: "${touchpad2_action}" + on_release: + then: + - output.turn_off: blue_led + + - platform: gpio + pin: + number: GPIO10 + mode: INPUT_PULLUP + inverted: True + name: "${friendly_name} Touchpad 3" + on_press: + then: + - output.turn_on: blue_led + - script.execute: "${touchpad3_action}" + on_release: + then: + - output.turn_off: blue_led + +script: + - id: sonoff_t3_toggle_relay_1 + then: + - switch.toggle: relay_1 + - id: sonoff_t3_toggle_relay_2 + then: + - switch.toggle: relay_2 + - id: sonoff_t3_toggle_relay_3 + then: + - switch.toggle: relay_3 + - id: sonoff_t3_toggle_relay_1_and_3 + then: + - switch.toggle: relay_1 + - switch.toggle: relay_3 diff --git a/ensuite-lightswitch.yaml b/ensuite-lightswitch.yaml new file mode 100644 index 0000000..3ee426f --- /dev/null +++ b/ensuite-lightswitch.yaml @@ -0,0 +1,11 @@ +substitutions: + hostname: ensuite-switch + friendly_name: En-Suite Switch + touchpad2_action: sonoff_t3_toggle_relay_1_and_3 + + +packages: + device: !include devices/sonoff-t3.yaml + +wifi: + use_address: 192.168.10.5 diff --git a/green-wax-melt.yaml b/green-wax-melt.yaml new file mode 100644 index 0000000..091a4e5 --- /dev/null +++ b/green-wax-melt.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: green-wax-melt + friendly_name: Green Wax Melt + +wifi: + use_address: 192.168.10.29 + +packages: + device: !include devices/sonoff-basic.yaml + diff --git a/grey-wax-melt.yaml b/grey-wax-melt.yaml new file mode 100644 index 0000000..979976d --- /dev/null +++ b/grey-wax-melt.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: grey-wax-melt + friendly_name: Grey Wax Melt + +wifi: + use_address: 192.168.10.32 + +packages: + device: !include devices/sonoff-basic.yaml + diff --git a/hall-by-front-door.yaml b/hall-by-front-door.yaml new file mode 100644 index 0000000..f5e3b90 --- /dev/null +++ b/hall-by-front-door.yaml @@ -0,0 +1,18 @@ +substitutions: + hostname: hall-by-front-door + friendly_name: Front Door Switch + touchpad1_action: toggle_landing_light + +wifi: + use_address: 192.168.10.6 + +packages: + device: !include devices/sonoff-t3.yaml + +script: + - id: toggle_landing_light + then: + - homeassistant.service: + service: homeassistant.toggle + data: + entity_id: "switch.landing_switch_relay_2" diff --git a/heated-blanket.yaml b/heated-blanket.yaml new file mode 100644 index 0000000..40d03a2 --- /dev/null +++ b/heated-blanket.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: heated-blanket-switch + friendly_name: Heated Blanket Switch + +wifi: + use_address: 192.168.10.31 + +packages: + device: !include devices/localbytes-plug.yaml + diff --git a/heating-downstairs.yaml b/heating-downstairs.yaml new file mode 100644 index 0000000..515c231 --- /dev/null +++ b/heating-downstairs.yaml @@ -0,0 +1,32 @@ +substitutions: + hostname: heating-downstairs + friendly_name: Heating Downstairs + relay_on_action: turn_on + +wifi: + use_address: 192.168.10.18 + +packages: + device: !include devices/sonoff-basic.yaml + +# Give the user a graphical control over the timeout +# See: https://esphome.io/components/number/template.html +number: + - name: "${friendly_name} Timeout" + id: timeout_length + platform: template + # TODO: maybe it's a better UX to do this in hours and minutes and do the conversion in esphome + unit_of_measurement: minutes + min_value: 10 + # Never want it on for more than 3 hours + # 3*60 = 180 + max_value: 180 + initial_value: 60 + step: 10 + optimistic: true + +script: + - id: turn_on + then: + - delay: !lambda 'return id(timeout_length).state * 60 * 1000;' + - lambda: !lambda id(relay).turn_off(); diff --git a/heating-upstairs.bac b/heating-upstairs.bac new file mode 100644 index 0000000..bcfb704 --- /dev/null +++ b/heating-upstairs.bac @@ -0,0 +1,77 @@ +substitutions: + hostname: heating-upstairs + friendly_name: Heating Upstairs + relay_on_action: turn_on_action + relay_off_action: turn_off_action + +wifi: + use_address: 192.168.10.17 + +packages: + device: !include devices/sonoff-basic.yaml + +globals: + - id: total_minutes + type: int + initial_value: "0" + - id: minutes_passed + type: int + initial_value: "0" + +# Give the user a graphical control over the timeout +# See: https://esphome.io/components/number/template.html +number: + - name: "${friendly_name} Timeout" + id: timeout_length + platform: template + # TODO: maybe it's a better UX to do this in hours and minutes and do the conversion in esphome + unit_of_measurement: minutes + # Min 5 minutes + min_value: 10 + # Never want it on for more than 3 hours + # 3*60 = 180 + max_value: 180 + initial_value: 10 + step: 10 + optimistic: true + +sensor: + - name: "${friendly_name} Total Time" + platform: template + lambda: !lambda 'return id(total_minutes);' + unit_of_measurement: 'minutes' + accuracy_decimals: 0 + - name: "${friendly_name} Elapsed Time" + platform: template + lambda: !lambda 'return id(minutes_passed);' + unit_of_measurement: 'minutes' + accuracy_decimals: 0 + + +script: + - id: turn_on_action + then: + - logger.log: "Turn On" + - lambda: |- + id(total_minutes) = id(timeout_length).state; + id(minutes_passed) = 0; + id(tick).execute(); + - id: turn_off_action + then: + - logger.log: "Turn Off" + - lambda: |- + id(relay).turn_off(); + id(minutes_passed) = 0; + id(total_minutes) = 0; + - id: tick + mode: queued + then: + - delay: 1min + - logger.log: "Tick" + - lambda: |- + id(minutes_passed) += 1; + if (id(minutes_passed) >= id(total_minutes) ) { + id(turn_off_action).execute(); + } else { + id(tick).execute(); + } diff --git a/heating-upstairs.yaml b/heating-upstairs.yaml new file mode 100644 index 0000000..c982cea --- /dev/null +++ b/heating-upstairs.yaml @@ -0,0 +1,33 @@ +substitutions: + hostname: heating-upstairs + friendly_name: Heating Upstairs + relay_on_action: turn_on + +wifi: + use_address: 192.168.10.17 + +packages: + device: !include devices/sonoff-basic.yaml + + +# Give the user a graphical control over the timeout +# See: https://esphome.io/components/number/template.html +number: + - name: "${friendly_name} Timeout" + id: timeout_length + platform: template + # TODO: maybe it's a better UX to do this in hours and minutes and do the conversion in esphome + unit_of_measurement: minutes + min_value: 10 + # Never want it on for more than 3 hours + # 3*60 = 180 + max_value: 180 + initial_value: 60 + step: 10 + optimistic: true + +script: + - id: turn_on + then: + - delay: !lambda 'return id(timeout_length).state * 60 * 1000;' + - lambda: !lambda id(relay).turn_off(); diff --git a/kitchen.yaml b/kitchen.yaml new file mode 100644 index 0000000..8aab5ba --- /dev/null +++ b/kitchen.yaml @@ -0,0 +1,13 @@ +substitutions: + hostname: kitchen-switch + friendly_name: Kitchen + #touchpad1_action: sonoff_t3_toggle_relay_2 + touchpad2_action: sonoff_t3_toggle_relay_1_and_3 + #touchpad3_action: sonoff_t3_toggle_relay_2 + +wifi: + use_address: 192.168.10.9 + +packages: + device: !include devices/sonoff-t3.yaml + diff --git a/landing-lightswitch.yaml b/landing-lightswitch.yaml new file mode 100644 index 0000000..2ec39f2 --- /dev/null +++ b/landing-lightswitch.yaml @@ -0,0 +1,13 @@ +substitutions: + hostname: landing-switch + friendly_name: Landing Switch + touchpad1_action: sonoff_t3_toggle_relay_2 + touchpad2_action: sonoff_t3_toggle_relay_2 + touchpad3_action: sonoff_t3_toggle_relay_2 + +wifi: + use_address: 192.168.10.4 + +packages: + device: !include devices/sonoff-t3.yaml + diff --git a/lounge-by-garden.yaml b/lounge-by-garden.yaml new file mode 100644 index 0000000..d6ba0fb --- /dev/null +++ b/lounge-by-garden.yaml @@ -0,0 +1,13 @@ +substitutions: + hostname: lounge-by-garden + friendly_name: Lounge 2 + #touchpad1_action: sonoff_t3_toggle_relay_2 + #touchpad2_action: sonoff_t3_toggle_relay_2 + #touchpad3_action: sonoff_t3_toggle_relay_2 + +wifi: + use_address: 192.168.10.8 + +packages: + device: !include devices/sonoff-t3.yaml + diff --git a/lounge-by-hall.yaml b/lounge-by-hall.yaml new file mode 100644 index 0000000..d84a7c7 --- /dev/null +++ b/lounge-by-hall.yaml @@ -0,0 +1,32 @@ +substitutions: + hostname: lounge-by-hall + friendly_name: Lounge 1 + touchpad1_action: toggle_lounge_light + touchpad2_action: toggle_lamp + touchpad3_action: toggle_dining_light + +wifi: + use_address: 192.168.10.7 + +packages: + device: !include devices/sonoff-t3.yaml + +script: + - id: toggle_lounge_light + then: + - homeassistant.service: + service: homeassistant.toggle + data: + entity_id: "light.lounge_light_1_bulb" + - id: toggle_dining_light + then: + - homeassistant.service: + service: homeassistant.toggle + data: + entity_id: "light.lounge_light_2_bulb" + - id: toggle_lamp + then: + - homeassistant.service: + service: homeassistant.toggle + data: + entity_id: "light.lounge_lamp_relay" diff --git a/lounge-lamp.yaml b/lounge-lamp.yaml new file mode 100644 index 0000000..303fd10 --- /dev/null +++ b/lounge-lamp.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: lounge-lamp + friendly_name: Lounge Lamp + +wifi: + use_address: 192.168.10.13 + +packages: + device: !include devices/sonoff-basic.yaml + diff --git a/lounge-light-1.yaml b/lounge-light-1.yaml new file mode 100644 index 0000000..9fc4fe5 --- /dev/null +++ b/lounge-light-1.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: lounge-light-1 + friendly_name: Lounge Light 1 + +wifi: + use_address: 192.168.10.19 + +packages: + device: !include devices/athom-bulb.yaml + diff --git a/lounge-light-2.yaml b/lounge-light-2.yaml new file mode 100644 index 0000000..605e834 --- /dev/null +++ b/lounge-light-2.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: lounge-light-2 + friendly_name: Lounge Light 2 + +wifi: + use_address: 192.168.10.24 + +packages: + device: !include devices/athom-bulb.yaml + diff --git a/man-cave-desk.yaml b/man-cave-desk.yaml new file mode 100644 index 0000000..9cb99ad --- /dev/null +++ b/man-cave-desk.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: man-cave-switch + friendly_name: Man Cave Desk Switch + +wifi: + use_address: 192.168.10.26 + +packages: + device: !include devices/localbytes-plug.yaml + diff --git a/man-cave-lightswitch.yaml b/man-cave-lightswitch.yaml new file mode 100644 index 0000000..e53263f --- /dev/null +++ b/man-cave-lightswitch.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: man-cave-switch + friendly_name: Man Cave Switch + +wifi: + use_address: 192.168.10.15 + +packages: + device: !include devices/sonoff-t3.yaml + diff --git a/office-atom-echo.yaml b/office-atom-echo.yaml new file mode 100644 index 0000000..b3f7678 --- /dev/null +++ b/office-atom-echo.yaml @@ -0,0 +1,201 @@ +substitutions: + hostname: office-atom-echo + friendly_name: Office Speaker + +packages: + base: !include common/base.yaml + sensors: !include common/basicSensors.yaml + +esphome: + name: ${hostname} + build_path: ./build/${hostname} + friendly_name: ${friendly_name} + +wifi: + use_address: 192.168.10.28 + +esp32: + board: m5stack-atom + +improv_serial: + +i2s_audio: + i2s_lrclk_pin: GPIO33 + i2s_bclk_pin: GPIO19 + + #microphone: + # - platform: i2s_audio + # id: echo_microphone + # i2s_din_pin: GPIO23 + # adc_type: external + # pdm: true + +speaker: + - platform: i2s_audio + id: echo_speaker + i2s_dout_pin: GPIO22 + dac_type: external + mode: mono + +media_player: + - platform: i2s_audio + id: echo_media + name: None + dac_type: external + i2s_dout_pin: GPIO22 + + + #voice_assistant: + # id: va + # microphone: echo_microphone + # speaker: echo_speaker + # noise_suppression_level: 2 + # auto_gain: 31dBFS + # volume_multiplier: 2.0 + # vad_threshold: 3 + # on_listening: + # - light.turn_on: + # id: led + # blue: 100% + # red: 0% + # green: 0% + # brightness: 100% + # effect: pulse + # on_tts_start: + # - light.turn_on: + # id: led + # blue: 0% + # red: 0% + # green: 100% + # brightness: 100% + # effect: pulse + # on_end: + # - delay: 100ms + # - wait_until: + # not: + # speaker.is_playing: + # - script.execute: reset_led + # on_error: + # - light.turn_on: + # id: led + # blue: 0% + # red: 100% + # green: 0% + # brightness: 100% + # effect: none + # - delay: 1s + # - script.execute: reset_led + # + # on_client_connected: + # - if: + # condition: + # switch.is_on: use_wake_word + # then: + # - voice_assistant.start_continuous: + # - script.execute: reset_led + # on_client_disconnected: + # - if: + # condition: + # switch.is_on: use_wake_word + # then: + # - voice_assistant.stop: + # - light.turn_off: led + +binary_sensor: + - platform: gpio + pin: + number: GPIO39 + inverted: true + name: Button + id: echo_button + #on_click: + # - if: + # condition: + # switch.is_off: use_wake_word + # then: + # - if: + # condition: voice_assistant.is_running + # then: + # - voice_assistant.stop: + # - script.execute: reset_led + # else: + # - voice_assistant.start: + # else: + # - voice_assistant.stop + # - delay: 1s + # - script.execute: reset_led + # - script.wait: reset_led + # - voice_assistant.start_continuous: + +light: + - platform: esp32_rmt_led_strip + id: led + name: light + entity_category: config + pin: GPIO27 + default_transition_length: 0s + chipset: SK6812 + num_leds: 1 + rgb_order: grb + rmt_channel: 0 + effects: + - pulse: + transition_length: 250ms + update_interval: 250ms + + #script: + # - id: reset_led + # then: + # - if: + # condition: + # - switch.is_on: use_wake_word + # - switch.is_on: use_listen_light + # then: + # - light.turn_on: + # id: led + # blue: 100% + # red: 100% + # green: 0% + # brightness: 100% + # effect: none + # else: + # - light.turn_off: led + + #switch: + # - platform: template + # name: Use wake word + # id: use_wake_word + # optimistic: true + # restore_mode: RESTORE_DEFAULT_ON + # entity_category: config + # on_turn_on: + # - lambda: id(va).set_use_wake_word(true); + # - if: + # condition: + # not: + # - voice_assistant.is_running + # then: + # - voice_assistant.start_continuous + # - script.execute: reset_led + # on_turn_off: + # - voice_assistant.stop + # - lambda: id(va).set_use_wake_word(false); + # - script.execute: reset_led + # - platform: template + # name: Use Listen Light + # id: use_listen_light + # optimistic: true + # restore_mode: RESTORE_DEFAULT_ON + # entity_category: config + # on_turn_on: + # - script.execute: reset_led + # on_turn_off: + # - script.execute: reset_led + # + #external_components: + # - source: github://pr#5230 + # components: + # - esp_adf + # refresh: 0s + + #esp_adf: diff --git a/secrets.yaml b/secrets.yaml deleted file mode 100644 index e1c34ad..0000000 Binary files a/secrets.yaml and /dev/null differ diff --git a/spare-room-lamp.yaml b/spare-room-lamp.yaml new file mode 100644 index 0000000..766e187 --- /dev/null +++ b/spare-room-lamp.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: spare-room-lamp + friendly_name: Spare Room Lamp + +wifi: + use_address: 192.168.10.21 + +packages: + device: !include devices/sonoff-basic.yaml + diff --git a/spare-room-lightswitch.yaml b/spare-room-lightswitch.yaml new file mode 100644 index 0000000..400e943 --- /dev/null +++ b/spare-room-lightswitch.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: spare-room-switch + friendly_name: Spare Room Switch + +wifi: + use_address: 192.168.10.14 + +packages: + device: !include devices/sonoff-t3.yaml + diff --git a/tv-switch.yaml b/tv-switch.yaml new file mode 100644 index 0000000..6e088a1 --- /dev/null +++ b/tv-switch.yaml @@ -0,0 +1,10 @@ +substitutions: + hostname: tv-switch + friendly_name: TV Switch + +wifi: + use_address: 192.168.10.20 + +packages: + device: !include devices/localbytes-plug.yaml +