Compare commits
2 Commits
23abe209a5
...
d9ca44a9ee
Author | SHA1 | Date | |
---|---|---|---|
|
d9ca44a9ee | ||
|
6034bc0320 |
@@ -1,11 +1,9 @@
|
|||||||
##########################################################################################
|
#############################################
|
||||||
##########################################################################################
|
#############################################
|
||||||
# MAIN DISHWASHER POWER
|
# OFFICE MULTI USB CONTROL
|
||||||
# Controlled by a Athom Smart Plug V1
|
# Controlled by a Sonoff Basic R1
|
||||||
# package_import_url: github://athom-tech/athom-configs/athom-smart-plug.yaml
|
|
||||||
#
|
#
|
||||||
# V1.1 2025-06-12 package added for energy entities
|
# V1.0 2025-06-18 Initial Version
|
||||||
# V1.0 2025-06-10 YAML Tidyups
|
|
||||||
#
|
#
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@@ -16,30 +14,36 @@
|
|||||||
##########################################################################################
|
##########################################################################################
|
||||||
substitutions:
|
substitutions:
|
||||||
# Device Naming
|
# Device Naming
|
||||||
device_name: "esp-maindishwasherpower"
|
device_name: "esp-officemultiusb"
|
||||||
friendly_name: "Main Dishwasher Power"
|
friendly_name: "Office Multi USB Control"
|
||||||
description_comment: "Main Dishwasher Power Monitor :: Athom Smart Plug Power Monitor V1"
|
mqtt_device_name: "office-multiusb-control"
|
||||||
device_area: "Kitchen" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
description_comment: "Multi USB control in the Office (behind monitors) :: Sonoff Basic"
|
||||||
|
device_area: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
# Project Naming
|
# Project Naming
|
||||||
project_name: "Athom Technology.Smart Plug V1" # Project Details
|
project_name: "Sonoff Technologies.Sonoff Basic V1" # Project Details
|
||||||
project_version: "v1.1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
project_version: "v1.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||||
|
|
||||||
# Passwords
|
# Passwords
|
||||||
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
|
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
static_ip_address: !secret esp-maindishwasherpower_ip
|
static_ip_address: !secret esp-officemultiusb_ip
|
||||||
|
mqtt_main_command_topic: !secret mqtt_main_command_topic
|
||||||
|
|
||||||
# Device Settings
|
# Device Settings
|
||||||
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
relay_icon: "mdi:generator-portable"
|
||||||
|
log_level: "ERROR" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
update_interval: "60s" # update time for for general sensors etc
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
# Device Settings
|
# MQTT Controls
|
||||||
relay_icon: "mdi:dishwasher"
|
mqtt_main_topic: "${mqtt_main_command_topic}/${mqtt_device_name}/operation" # Topic we will use to command stuff from external withougt HA
|
||||||
current_limit : "10" # Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
|
#mqtt_status_topic: "${mqtt_main_status_topic}/esphome/${device_name}" # Topic we will use to read stuff from external withougt HA
|
||||||
|
#mqtt_main_status_topic: !secret mqtt_main_status_topic
|
||||||
|
#mqtt_remote_device1_command_topic: "${mqtt_main_command_topic}/masterbath-towelrail/operation"
|
||||||
|
#mqtt_remote_device1_command1: "BOOST"
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# PACKAGES
|
# PACKAGES: Included Common Packages
|
||||||
# https://esphome.io/components/esphome.html
|
# https://esphome.io/components/esphome.html
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
packages:
|
packages:
|
||||||
@@ -52,6 +56,10 @@ packages:
|
|||||||
file: common/api_common.yaml
|
file: common/api_common.yaml
|
||||||
vars:
|
vars:
|
||||||
local_api_key: "${api_key}"
|
local_api_key: "${api_key}"
|
||||||
|
#common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
common_sntp: !include
|
common_sntp: !include
|
||||||
file: common/sntp_common.yaml
|
file: common/sntp_common.yaml
|
||||||
common_general_sensors: !include
|
common_general_sensors: !include
|
||||||
@@ -60,20 +68,6 @@ packages:
|
|||||||
local_friendly_name: "${friendly_name}"
|
local_friendly_name: "${friendly_name}"
|
||||||
local_update_interval: "${update_interval}"
|
local_update_interval: "${update_interval}"
|
||||||
|
|
||||||
# Web and MQTT Packages
|
|
||||||
#common_webportal: !include
|
|
||||||
# file: common/webportal_common.yaml
|
|
||||||
#common_mqtt: !include
|
|
||||||
# file: common/mqtt_common.yaml
|
|
||||||
|
|
||||||
|
|
||||||
# Device Specific included packages
|
|
||||||
common_athompowermonV1: !include
|
|
||||||
file: common/athompowermonv1_common.yaml
|
|
||||||
vars:
|
|
||||||
local_friendly_name: "${friendly_name}"
|
|
||||||
local_current_limit: "${current_limit}"
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# ESPHome
|
# ESPHome
|
||||||
# https://esphome.io/components/esphome.html
|
# https://esphome.io/components/esphome.html
|
||||||
@@ -83,60 +77,63 @@ esphome:
|
|||||||
friendly_name: "${friendly_name}"
|
friendly_name: "${friendly_name}"
|
||||||
comment: "${description_comment}" # Appears on the esphome page in HA
|
comment: "${description_comment}" # Appears on the esphome page in HA
|
||||||
area: "${device_area}"
|
area: "${device_area}"
|
||||||
name_add_mac_suffix: False
|
# platformio_options:
|
||||||
min_version: 2024.6.0
|
# build_flags:
|
||||||
project:
|
# - "-Os" # optimize for size
|
||||||
name: "${project_name}"
|
# - "-Wl,--gc-sections" # drop unused code/data
|
||||||
version: "${project_version}"
|
# - "-fno-exceptions" # strip C++ exceptions
|
||||||
on_boot:
|
# - "-fno-rtti" # strip C++ RTTI
|
||||||
priority: 200
|
|
||||||
then:
|
|
||||||
- switch.turn_on: "relay"
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# ESP Platform and Framework
|
# ESP Platform and Framework
|
||||||
# https://esphome.io/components/esp32.html
|
# https://esphome.io/components/esp32.html
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
esp8266:
|
esp8266:
|
||||||
board: esp8285
|
board: esp01_1m # The original sonoff basic
|
||||||
restore_from_flash: true # mainly for calculating cumulative energy, but not that important here
|
restore_from_flash: True # restore some values on reboot
|
||||||
|
|
||||||
preferences:
|
preferences:
|
||||||
flash_write_interval: 5min
|
flash_write_interval: 5min
|
||||||
|
|
||||||
mdns:
|
mdns:
|
||||||
disabled: false
|
disabled: False
|
||||||
|
|
||||||
#dashboard_import:
|
|
||||||
# package_import_url: github://athom-tech/esp32-configs/athom-smart-plug.yaml
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# ESPHome LOGGING
|
# ESPHome Logging Enable
|
||||||
# https://esphome.io/components/logger.html
|
# https://esphome.io/components/logger.html
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
logger:
|
logger:
|
||||||
level: "${log_level}" #INFO Level suggested, or DEBUG for testing
|
level: "${log_level}" #INFO Level suggested, or DEBUG for testing
|
||||||
#baud_rate: 0 # set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
baud_rate: 0 # set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
#esp8266_store_log_strings_in_flash: false
|
#esp8266_store_log_strings_in_flash: false
|
||||||
#tx_buffer_size: 64
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# STATUS LED
|
# SWITCH COMPONENT
|
||||||
# https://esphome.io/components/status_led.html
|
# https://esphome.io/components/switch/
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
status_led:
|
# Sonoff Basic R1 Relay Switch is GPIO12
|
||||||
pin:
|
#############################################
|
||||||
number: GPIO13
|
switch:
|
||||||
inverted: True
|
- platform: gpio
|
||||||
|
name: "ELV Power Supply"
|
||||||
|
pin: GPIO12
|
||||||
|
id: relay1
|
||||||
|
restore_mode: RESTORE_DEFAULT_ON
|
||||||
|
icon: "${relay_icon}"
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# BINARY SENSORS
|
# BINARY SENSORS
|
||||||
# https://esphome.io/components/binary_sensor/
|
# https://esphome.io/components/binary_sensor/
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
# Sonoff Basic R1 Button is GPIO03
|
||||||
|
#############################################
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
|
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
pin:
|
pin:
|
||||||
number: 3
|
number: GPIO03
|
||||||
mode: INPUT_PULLUP
|
mode: INPUT_PULLUP
|
||||||
inverted: true
|
inverted: true
|
||||||
name: "Power Button"
|
name: "Power Button"
|
||||||
@@ -147,24 +144,45 @@ binary_sensor:
|
|||||||
- min_length: 20ms
|
- min_length: 20ms
|
||||||
max_length: 500ms
|
max_length: 500ms
|
||||||
then:
|
then:
|
||||||
- switch.toggle:
|
- lambda: |-
|
||||||
id: relay
|
if (id(relay1).state) {
|
||||||
|
// Relay is ON: turn it OFF
|
||||||
|
id(relay1).turn_off();
|
||||||
|
} else {
|
||||||
|
// Relay is OFF: turn it ON
|
||||||
|
id(relay1).turn_on();
|
||||||
|
}
|
||||||
|
|
||||||
|
# Mimics actual relay status (but not controllable)
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Relay Status"
|
name: "Relay Status"
|
||||||
lambda: |-
|
lambda: |-
|
||||||
return id(relay).state;
|
return id(relay1).state;
|
||||||
|
|
||||||
#################################################################################################
|
##########################################################################################
|
||||||
# SWITCH COMPONENT
|
# STATUS LED
|
||||||
# https://esphome.io/components/switch/
|
# https://esphome.io/components/status_led.html
|
||||||
#################################################################################################
|
##########################################################################################
|
||||||
switch:
|
# Sonoff Basic R1 LED is GPIO13
|
||||||
- platform: gpio
|
#############################################
|
||||||
name: "Power Output"
|
status_led:
|
||||||
pin: GPIO14
|
pin:
|
||||||
id: relay
|
number: GPIO13
|
||||||
restore_mode: RESTORE_DEFAULT_OFF # Ensures the relay is restored (or off) at boot
|
inverted: yes
|
||||||
#internal: true # Hides the switch from Home Assistant
|
|
||||||
icon: "${relay_icon}"
|
##########################################################################################
|
||||||
|
# MQTT COMMANDS
|
||||||
|
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||||
|
##########################################################################################
|
||||||
|
mqtt:
|
||||||
|
on_message:
|
||||||
|
# Relay 1 control
|
||||||
|
- topic: "${mqtt_main_topic}/relay1/set"
|
||||||
|
payload: "ON"
|
||||||
|
then:
|
||||||
|
- switch.turn_on: relay1
|
||||||
|
- topic: "${mqtt_main_topic}/relay1/set"
|
||||||
|
payload: "OFF"
|
||||||
|
then:
|
||||||
|
- switch.turn_off: relay1
|
||||||
|
|
@@ -19,7 +19,7 @@
|
|||||||
#############################################
|
#############################################
|
||||||
substitutions:
|
substitutions:
|
||||||
# Device Naming
|
# Device Naming
|
||||||
devicename: "esp-downstbathswitch"
|
device_name: "esp-downstbathswitch"
|
||||||
friendly_name: "Downstairs Bath Lightswitch (3)"
|
friendly_name: "Downstairs Bath Lightswitch (3)"
|
||||||
description_comment: "Downstairs Bathroom Main Lightswitch using a Zemismart KS-811 Triple Push Button. Main Light (1), Cabinet Light (2), Extract Fan (3)"
|
description_comment: "Downstairs Bathroom Main Lightswitch using a Zemismart KS-811 Triple Push Button. Main Light (1), Cabinet Light (2), Extract Fan (3)"
|
||||||
device_area: "Downstairs Bathroom" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
device_area: "Downstairs Bathroom" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
@@ -73,7 +73,7 @@ packages:
|
|||||||
# https://esphome.io/components/esphome.html
|
# https://esphome.io/components/esphome.html
|
||||||
#############################################
|
#############################################
|
||||||
esphome:
|
esphome:
|
||||||
name: "${devicename}"
|
name: "${device_name}"
|
||||||
friendly_name: "${friendly_name}"
|
friendly_name: "${friendly_name}"
|
||||||
comment: "${description_comment}" #Appears on the esphome page in HA
|
comment: "${description_comment}" #Appears on the esphome page in HA
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ substitutions:
|
|||||||
static_ip_address: !secret esp-downstdishwpower_ip
|
static_ip_address: !secret esp-downstdishwpower_ip
|
||||||
|
|
||||||
# Device Settings
|
# Device Settings
|
||||||
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
log_level: "NONE" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
update_interval: "60s" # update time for for general sensors etc
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
# Device Settings
|
# Device Settings
|
||||||
|
@@ -27,7 +27,6 @@ substitutions:
|
|||||||
friendly_name: "Office Dual Lights"
|
friendly_name: "Office Dual Lights"
|
||||||
description_comment: "Dual Office Lights (Overhead and right hand Bunker) :: Sonoff Dual R1"
|
description_comment: "Dual Office Lights (Overhead and right hand Bunker) :: Sonoff Dual R1"
|
||||||
device_area: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
device_area: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
mqtt_device_name: "office-dual-lights"
|
|
||||||
|
|
||||||
# Project Naming
|
# Project Naming
|
||||||
project_name: "Sonoff Technologies.Sonoff Dual R1" # Project Details
|
project_name: "Sonoff Technologies.Sonoff Dual R1" # Project Details
|
||||||
@@ -37,7 +36,6 @@ substitutions:
|
|||||||
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
|
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
static_ip_address: !secret esp-officeduallights_ip
|
static_ip_address: !secret esp-officeduallights_ip
|
||||||
mqtt_main_command_topic: !secret mqtt_main_command_topic
|
|
||||||
|
|
||||||
# Device Settings
|
# Device Settings
|
||||||
relay_icon: "mdi:lightbulb-group"
|
relay_icon: "mdi:lightbulb-group"
|
||||||
@@ -45,6 +43,8 @@ substitutions:
|
|||||||
update_interval: "60s" # update time for for general sensors etc
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
# MQTT Controls
|
# MQTT Controls
|
||||||
|
mqtt_device_name: "office-dual-lights"
|
||||||
|
mqtt_main_command_topic: !secret mqtt_main_command_topic
|
||||||
mqtt_topic: "${mqtt_main_command_topic}/${mqtt_device_name}" # Topic we will use to command stuff from external withougt HA
|
mqtt_topic: "${mqtt_main_command_topic}/${mqtt_device_name}" # Topic we will use to command stuff from external withougt HA
|
||||||
#mqtt_status_topic: "${mqtt_main_status_topic}/esphome/${device_name}" # Topic we will use to read stuff from external withougt HA
|
#mqtt_status_topic: "${mqtt_main_status_topic}/esphome/${device_name}" # Topic we will use to read stuff from external withougt HA
|
||||||
#mqtt_main_status_topic: !secret mqtt_main_status_topic
|
#mqtt_main_status_topic: !secret mqtt_main_status_topic
|
||||||
|
@@ -16,7 +16,6 @@ substitutions:
|
|||||||
# Device Naming
|
# Device Naming
|
||||||
device_name: "esp-officeelvcontrol"
|
device_name: "esp-officeelvcontrol"
|
||||||
friendly_name: "Office ELV Control"
|
friendly_name: "Office ELV Control"
|
||||||
mqtt_device_name: "office-elv-control"
|
|
||||||
description_comment: "ELV Power Supply control in the Office (under desk) :: Sonoff Basic"
|
description_comment: "ELV Power Supply control in the Office (under desk) :: Sonoff Basic"
|
||||||
device_area: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
device_area: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
@@ -35,12 +34,13 @@ substitutions:
|
|||||||
log_level: "ERROR" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
log_level: "ERROR" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
update_interval: "60s" # update time for for general sensors etc
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
|
# Device Naming
|
||||||
|
relay_1_name: "Office ELV Power Supply"
|
||||||
|
button_1_name: "Power Button"
|
||||||
|
|
||||||
# MQTT Controls
|
# MQTT Controls
|
||||||
mqtt_command_topic: "${mqtt_main_command_topic}/${mqtt_device_name}/operation" # Topic we will use to command stuff from external withougt HA
|
mqtt_device_name: "office-elv-control"
|
||||||
#mqtt_status_topic: "${mqtt_main_status_topic}/esphome/${device_name}" # Topic we will use to read stuff from external withougt HA
|
mqtt_main_topic: "${mqtt_main_command_topic}/${mqtt_device_name}" # Topic we will use to command stuff from external without HA
|
||||||
#mqtt_main_status_topic: !secret mqtt_main_status_topic
|
|
||||||
#mqtt_remote_device1_command_topic: "${mqtt_main_command_topic}/masterbath-towelrail/operation"
|
|
||||||
#mqtt_remote_device1_command1: "BOOST"
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# PACKAGES: Included Common Packages
|
# PACKAGES: Included Common Packages
|
||||||
@@ -84,7 +84,6 @@ esphome:
|
|||||||
# - "-fno-exceptions" # strip C++ exceptions
|
# - "-fno-exceptions" # strip C++ exceptions
|
||||||
# - "-fno-rtti" # strip C++ RTTI
|
# - "-fno-rtti" # strip C++ RTTI
|
||||||
|
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# ESP Platform and Framework
|
# ESP Platform and Framework
|
||||||
# https://esphome.io/components/esp32.html
|
# https://esphome.io/components/esp32.html
|
||||||
@@ -117,10 +116,10 @@ logger:
|
|||||||
#############################################
|
#############################################
|
||||||
switch:
|
switch:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: "ELV Power Supply"
|
name: "${relay_1_name}"
|
||||||
pin: GPIO12
|
pin: GPIO12
|
||||||
id: relay
|
id: relay1
|
||||||
restore_mode: RESTORE_DEFAULT_OFF
|
restore_mode: RESTORE_DEFAULT_ON
|
||||||
icon: "${relay_icon}"
|
icon: "${relay_icon}"
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@@ -136,7 +135,7 @@ binary_sensor:
|
|||||||
number: GPIO03
|
number: GPIO03
|
||||||
mode: INPUT_PULLUP
|
mode: INPUT_PULLUP
|
||||||
inverted: true
|
inverted: true
|
||||||
name: "Power Button"
|
name: "${button_1_name}"
|
||||||
id: power_button
|
id: power_button
|
||||||
filters:
|
filters:
|
||||||
- delayed_on: 20ms
|
- delayed_on: 20ms
|
||||||
@@ -145,19 +144,27 @@ binary_sensor:
|
|||||||
max_length: 500ms
|
max_length: 500ms
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
if (id(relay).state) {
|
if (id(relay1).state) {
|
||||||
// Relay is ON: turn it OFF
|
// Relay is ON: turn it OFF
|
||||||
id(relay).turn_off();
|
id(relay1).turn_off();
|
||||||
} else {
|
} else {
|
||||||
// Relay is OFF: turn it ON
|
// Relay is OFF: turn it ON
|
||||||
id(relay).turn_on();
|
id(relay1).turn_on();
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mimics actual relay status (but not controllable)
|
# Mimics actual relay status (but not controllable)
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Relay Status"
|
name: "${relay_1_name} Status"
|
||||||
lambda: |-
|
lambda: |-
|
||||||
return id(relay).state;
|
return id(relay1).state;
|
||||||
|
on_press:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_topic}/relay1/state"
|
||||||
|
payload: "ON"
|
||||||
|
on_release:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_topic}/relay1/state"
|
||||||
|
payload: "OFF"
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# STATUS LED
|
# STATUS LED
|
||||||
@@ -171,22 +178,18 @@ status_led:
|
|||||||
inverted: yes
|
inverted: yes
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Text Sensors
|
# MQTT COMMANDS
|
||||||
# https://esphome.io/components/text_sensor/index.html
|
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
text_sensor:
|
mqtt:
|
||||||
- platform: mqtt_subscribe
|
on_message:
|
||||||
name: "Office ELV MQTT Command"
|
# Relay 1 control
|
||||||
id: office_elv_cmd
|
- topic: "${mqtt_main_topic}/relay1/set"
|
||||||
topic: "${mqtt_command_topic}"
|
payload: "ON"
|
||||||
internal: true # hide from HA
|
|
||||||
on_value:
|
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- switch.turn_on: relay1
|
||||||
// payload is x (std::string)
|
- topic: "${mqtt_main_topic}/relay1/set"
|
||||||
if (x == "ON") {
|
payload: "OFF"
|
||||||
id(relay).turn_on();
|
then:
|
||||||
} else if (x == "OFF") {
|
- switch.turn_off: relay1
|
||||||
id(relay).turn_off();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
195
esphome/esp-officeusbhubpower.yaml
Normal file
195
esphome/esp-officeusbhubpower.yaml
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# OFFICE USB HUB POWER
|
||||||
|
# Controlled by a Sonoff Basic R1
|
||||||
|
#
|
||||||
|
# V1.0 2025-06-14 Initial Version
|
||||||
|
#
|
||||||
|
##########################################################################################
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
##########################################################################################
|
||||||
|
substitutions:
|
||||||
|
# Device Naming
|
||||||
|
device_name: "esp-officeusbhubpower"
|
||||||
|
friendly_name: "Office USB Hub Power"
|
||||||
|
description_comment: "Office USB Hub Power Supply control in the Office (On wall) :: Sonoff Basic"
|
||||||
|
device_area: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
|
# Project Naming
|
||||||
|
project_name: "Sonoff Technologies.Sonoff Basic V1" # Project Details
|
||||||
|
project_version: "v1.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||||
|
|
||||||
|
# Passwords
|
||||||
|
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-officeusbhubpower_ip
|
||||||
|
mqtt_main_command_topic: !secret mqtt_main_command_topic
|
||||||
|
|
||||||
|
# Device Settings
|
||||||
|
relay_icon: "mdi:generator-portable"
|
||||||
|
log_level: "ERROR" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
|
# Device Naming
|
||||||
|
relay_1_name: "USB Hub Power Supply"
|
||||||
|
button_1_name: "Power Button"
|
||||||
|
|
||||||
|
# MQTT Controls
|
||||||
|
mqtt_device_name: "office-usbhub-power"
|
||||||
|
mqtt_main_topic: "${mqtt_main_command_topic}/${mqtt_device_name}" # Topic we will use to command stuff from external without HA
|
||||||
|
|
||||||
|
#########################################################################################
|
||||||
|
# PACKAGES: Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
##########################################################################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: "${static_ip_address}"
|
||||||
|
local_ota_pass: "${ota_pass}"
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: "${api_key}"
|
||||||
|
#common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: "${friendly_name}"
|
||||||
|
local_update_interval: "${update_interval}"
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
##########################################################################################
|
||||||
|
esphome:
|
||||||
|
name: "${device_name}"
|
||||||
|
friendly_name: "${friendly_name}"
|
||||||
|
comment: "${description_comment}" # Appears on the esphome page in HA
|
||||||
|
area: "${device_area}"
|
||||||
|
# platformio_options:
|
||||||
|
# build_flags:
|
||||||
|
# - "-Os" # optimize for size
|
||||||
|
# - "-Wl,--gc-sections" # drop unused code/data
|
||||||
|
# - "-fno-exceptions" # strip C++ exceptions
|
||||||
|
# - "-fno-rtti" # strip C++ RTTI
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
##########################################################################################
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m # The original sonoff basic
|
||||||
|
restore_from_flash: True # restore some values on reboot
|
||||||
|
|
||||||
|
preferences:
|
||||||
|
flash_write_interval: 5min
|
||||||
|
|
||||||
|
mdns:
|
||||||
|
disabled: False
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
##########################################################################################
|
||||||
|
logger:
|
||||||
|
level: "${log_level}" #INFO Level suggested, or DEBUG for testing
|
||||||
|
baud_rate: 0 # set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# SWITCH COMPONENT
|
||||||
|
# https://esphome.io/components/switch/
|
||||||
|
##########################################################################################
|
||||||
|
# Sonoff Basic R1 Relay Switch is GPIO12
|
||||||
|
#############################################
|
||||||
|
switch:
|
||||||
|
- platform: gpio
|
||||||
|
name: "${relay_1_name}"
|
||||||
|
pin: GPIO12
|
||||||
|
id: relay1
|
||||||
|
restore_mode: RESTORE_DEFAULT_ON
|
||||||
|
icon: "${relay_icon}"
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# BINARY SENSORS
|
||||||
|
# https://esphome.io/components/binary_sensor/
|
||||||
|
##########################################################################################
|
||||||
|
# Sonoff Basic R1 Button is GPIO03
|
||||||
|
#############################################
|
||||||
|
binary_sensor:
|
||||||
|
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO03
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: true
|
||||||
|
name: "${button_1_name}"
|
||||||
|
id: power_button
|
||||||
|
filters:
|
||||||
|
- delayed_on: 20ms
|
||||||
|
on_click:
|
||||||
|
- min_length: 20ms
|
||||||
|
max_length: 500ms
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
if (id(relay1).state) {
|
||||||
|
// Relay is ON: turn it OFF
|
||||||
|
id(relay1).turn_off();
|
||||||
|
} else {
|
||||||
|
// Relay is OFF: turn it ON
|
||||||
|
id(relay1).turn_on();
|
||||||
|
}
|
||||||
|
|
||||||
|
# Mimics actual relay status (but not controllable)
|
||||||
|
- platform: template
|
||||||
|
name: "${relay_1_name} Status"
|
||||||
|
lambda: |-
|
||||||
|
return id(relay1).state;
|
||||||
|
on_press:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_topic}/relay1/state"
|
||||||
|
payload: "ON"
|
||||||
|
on_release:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "${mqtt_topic}/relay1/state"
|
||||||
|
payload: "OFF"
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# STATUS LED
|
||||||
|
# https://esphome.io/components/status_led.html
|
||||||
|
##########################################################################################
|
||||||
|
# Sonoff Basic R1 LED is GPIO13
|
||||||
|
#############################################
|
||||||
|
status_led:
|
||||||
|
pin:
|
||||||
|
number: GPIO13
|
||||||
|
inverted: yes
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# MQTT COMMANDS
|
||||||
|
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||||
|
##########################################################################################
|
||||||
|
mqtt:
|
||||||
|
on_message:
|
||||||
|
# Relay 1 control
|
||||||
|
- topic: "${mqtt_main_topic}/relay1/set"
|
||||||
|
payload: "ON"
|
||||||
|
then:
|
||||||
|
- switch.turn_on: relay1
|
||||||
|
- topic: "${mqtt_main_topic}/relay1/set"
|
||||||
|
payload: "OFF"
|
||||||
|
then:
|
||||||
|
- switch.turn_off: relay1
|
||||||
|
|
@@ -6,6 +6,7 @@
|
|||||||
# dashboard_import:
|
# dashboard_import:
|
||||||
# package_import_url: github://athom-tech/esp32-configs/athom-smart-plug.yaml
|
# package_import_url: github://athom-tech/esp32-configs/athom-smart-plug.yaml
|
||||||
#
|
#
|
||||||
|
# V2.3 2025-06-19 Minor changes to remember mode in reboot and to ensure offline functionality
|
||||||
# V2.2 2025-06-14 Fixes to offline time when sntp/network unavailable
|
# V2.2 2025-06-14 Fixes to offline time when sntp/network unavailable
|
||||||
# V2.1 2025-06-12 Added select and button to chose modes, added countdown & startup to boost
|
# V2.1 2025-06-12 Added select and button to chose modes, added countdown & startup to boost
|
||||||
# V2.0 2025-06-05 YAML Tidyups
|
# V2.0 2025-06-05 YAML Tidyups
|
||||||
@@ -218,7 +219,7 @@ globals:
|
|||||||
####################################################
|
####################################################
|
||||||
- id: operation_mode
|
- id: operation_mode
|
||||||
type: int
|
type: int
|
||||||
restore_value: false
|
restore_value: True
|
||||||
initial_value: "2"
|
initial_value: "2"
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
@@ -229,7 +230,7 @@ globals:
|
|||||||
####################################################
|
####################################################
|
||||||
- id: current_mins
|
- id: current_mins
|
||||||
type: int
|
type: int
|
||||||
restore_value: false
|
restore_value: true
|
||||||
initial_value: "720" # 720 is 12:00 Noon
|
initial_value: "720" # 720 is 12:00 Noon
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
@@ -239,7 +240,7 @@ globals:
|
|||||||
####################################################
|
####################################################
|
||||||
- id: boost_timer
|
- id: boost_timer
|
||||||
type: int
|
type: int
|
||||||
restore_value: false
|
restore_value: true
|
||||||
initial_value: "0"
|
initial_value: "0"
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@@ -555,7 +556,7 @@ switch:
|
|||||||
pin: GPIO5
|
pin: GPIO5
|
||||||
id: relay
|
id: relay
|
||||||
restore_mode: RESTORE_DEFAULT_OFF # Ensures the relay is restored (or off) at boot
|
restore_mode: RESTORE_DEFAULT_OFF # Ensures the relay is restored (or off) at boot
|
||||||
#internal: true # Hides the switch from Home Assistant
|
#internal: true # Hides the switch from Home Assistant
|
||||||
icon: "${relay_icon}"
|
icon: "${relay_icon}"
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
263
esphome/esp-underhouselights.yaml
Normal file
263
esphome/esp-underhouselights.yaml
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
#############################################
|
||||||
|
#############################################
|
||||||
|
# UNDERHOUSE LIGHTS
|
||||||
|
# Controlled by a Sonoff 4Ch R2
|
||||||
|
# https://github.com/jvyoralek/homeassistant-config/blob/master/esphome/sonoff-4ch.yaml
|
||||||
|
#
|
||||||
|
# V1.0 2025-06-18 Initial Version
|
||||||
|
#
|
||||||
|
##########################################################################################
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
|
||||||
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
|
##########################################################################################
|
||||||
|
substitutions:
|
||||||
|
# Device Naming
|
||||||
|
device_name: "esp-underhouselights"
|
||||||
|
friendly_name: "Underhouse Lights"
|
||||||
|
description_comment: "Underhouse Lights Control :: Sonoff 4Ch R2"
|
||||||
|
device_area: "Underhouse" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||||
|
|
||||||
|
# Project Naming
|
||||||
|
project_name: "Sonoff Technologies.Sonoff 4Ch R2" # Project Details
|
||||||
|
project_version: "v1.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||||
|
|
||||||
|
# Passwords
|
||||||
|
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
||||||
|
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||||
|
static_ip_address: !secret esp-underhouselights_ip
|
||||||
|
mqtt_main_command_topic: !secret mqtt_main_command_topic
|
||||||
|
|
||||||
|
# Device Settings
|
||||||
|
log_level: "ERROR" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||||
|
update_interval: "60s" # update time for for general sensors etc
|
||||||
|
|
||||||
|
# MQTT Controls
|
||||||
|
mqtt_device_name: "underhouse-lights-control"
|
||||||
|
mqtt_main_topic: "${mqtt_main_command_topic}/${mqtt_device_name}" # Topic we will use to command stuff from external without HA
|
||||||
|
|
||||||
|
# Switch Naming
|
||||||
|
switch_1_name: "Underhouse Entrance Lights"
|
||||||
|
button_1_name: "Button 1"
|
||||||
|
relay_1_icon: "mdi:lightbulb"
|
||||||
|
switch_2_name: "Underhouse Storage Lights"
|
||||||
|
button_2_name: "Button 2"
|
||||||
|
relay_2_icon: "mdi:lightbulb"
|
||||||
|
switch_3_name: "Spare 3"
|
||||||
|
button_3_name: "Button 3"
|
||||||
|
relay_3_icon: "mdi:lightbulb"
|
||||||
|
switch_4_name: "Spare 4"
|
||||||
|
button_4_name: "Button 4"
|
||||||
|
relay_4_icon: "mdi:lightbulb"
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# PACKAGES: Included Common Packages
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
##########################################################################################
|
||||||
|
packages:
|
||||||
|
common_wifi: !include
|
||||||
|
file: common/network_common.yaml
|
||||||
|
vars:
|
||||||
|
local_static_ip_address: "${static_ip_address}"
|
||||||
|
local_ota_pass: "${ota_pass}"
|
||||||
|
common_api: !include
|
||||||
|
file: common/api_common.yaml
|
||||||
|
vars:
|
||||||
|
local_api_key: "${api_key}"
|
||||||
|
#common_webportal: !include
|
||||||
|
# file: common/webportal_common.yaml
|
||||||
|
common_mqtt: !include
|
||||||
|
file: common/mqtt_common.yaml
|
||||||
|
common_sntp: !include
|
||||||
|
file: common/sntp_common.yaml
|
||||||
|
common_general_sensors: !include
|
||||||
|
file: common/sensors_common.yaml
|
||||||
|
vars:
|
||||||
|
local_friendly_name: "${friendly_name}"
|
||||||
|
local_update_interval: "${update_interval}"
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# ESPHome
|
||||||
|
# https://esphome.io/components/esphome.html
|
||||||
|
##########################################################################################
|
||||||
|
esphome:
|
||||||
|
name: "${device_name}"
|
||||||
|
friendly_name: "${friendly_name}"
|
||||||
|
comment: "${description_comment}" # Appears on the esphome page in HA
|
||||||
|
area: "${device_area}"
|
||||||
|
# platformio_options:
|
||||||
|
# build_flags:
|
||||||
|
# - "-Os" # optimize for size
|
||||||
|
# - "-Wl,--gc-sections" # drop unused code/data
|
||||||
|
# - "-fno-exceptions" # strip C++ exceptions
|
||||||
|
# - "-fno-rtti" # strip C++ RTTI
|
||||||
|
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# ESP Platform and Framework
|
||||||
|
# https://esphome.io/components/esp32.html
|
||||||
|
##########################################################################################
|
||||||
|
esp8266:
|
||||||
|
board: esp01_1m # The original sonoff basic
|
||||||
|
restore_from_flash: True # restore some values on reboot
|
||||||
|
|
||||||
|
preferences:
|
||||||
|
flash_write_interval: 5min
|
||||||
|
|
||||||
|
mdns:
|
||||||
|
disabled: False
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# ESPHome Logging Enable
|
||||||
|
# https://esphome.io/components/logger.html
|
||||||
|
##########################################################################################
|
||||||
|
logger:
|
||||||
|
level: "${log_level}" #INFO Level suggested, or DEBUG for testing
|
||||||
|
baud_rate: 0 # set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
|
||||||
|
#esp8266_store_log_strings_in_flash: false
|
||||||
|
#tx_buffer_size: 64
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# SWITCH COMPONENT
|
||||||
|
# https://esphome.io/components/switch/
|
||||||
|
##########################################################################################
|
||||||
|
# Sonoff 4Ch R2 Relays are GPIO12,05,04,15
|
||||||
|
#############################################
|
||||||
|
switch:
|
||||||
|
- platform: gpio
|
||||||
|
id: relay1
|
||||||
|
name: "${switch_1_name}"
|
||||||
|
pin: GPIO12
|
||||||
|
icon: "${relay_1_icon}"
|
||||||
|
- platform: gpio
|
||||||
|
id: relay2
|
||||||
|
name: "${switch_2_name}"
|
||||||
|
pin: GPIO5
|
||||||
|
icon: "${relay_2_icon}"
|
||||||
|
- platform: gpio
|
||||||
|
id: relay3
|
||||||
|
name: "${switch_3_name}"
|
||||||
|
pin: GPIO4
|
||||||
|
icon: "${relay_3_icon}"
|
||||||
|
- platform: gpio
|
||||||
|
id: relay4
|
||||||
|
name: "${switch_4_name}"
|
||||||
|
pin: GPIO15
|
||||||
|
icon: "${relay_4_icon}"
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# BINARY SENSORS
|
||||||
|
# https://esphome.io/components/binary_sensor/
|
||||||
|
##########################################################################################
|
||||||
|
# Sonoff 4Ch R2 Buttons are GPIO00,09,10,14
|
||||||
|
#############################################
|
||||||
|
binary_sensor:
|
||||||
|
- platform: gpio
|
||||||
|
id: button1
|
||||||
|
name: "${button_1_name}"
|
||||||
|
pin:
|
||||||
|
number: GPIO0
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: True
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: relay1
|
||||||
|
- platform: gpio
|
||||||
|
id: button2
|
||||||
|
name: "${button_2_name}"
|
||||||
|
pin:
|
||||||
|
number: GPIO9
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: True
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: relay2
|
||||||
|
- platform: gpio
|
||||||
|
id: button3
|
||||||
|
name: "${button_3_name}"
|
||||||
|
pin:
|
||||||
|
number: GPIO10
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: True
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: relay3
|
||||||
|
- platform: gpio
|
||||||
|
id: button4
|
||||||
|
name: "${button_4_name}"
|
||||||
|
pin:
|
||||||
|
number: GPIO14
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: True
|
||||||
|
on_press:
|
||||||
|
- switch.toggle: relay4
|
||||||
|
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO03
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: true
|
||||||
|
name: "${switch_1_name} Remote Switch"
|
||||||
|
id: light_button_1
|
||||||
|
filters:
|
||||||
|
- delayed_on: 20ms
|
||||||
|
on_click:
|
||||||
|
- min_length: 20ms
|
||||||
|
max_length: 500ms
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
if (id(relay1).state) {
|
||||||
|
// Relay is ON: turn it OFF
|
||||||
|
id(relay1).turn_off();
|
||||||
|
} else {
|
||||||
|
// Relay is OFF: turn it ON
|
||||||
|
id(relay1).turn_on();
|
||||||
|
}
|
||||||
|
- platform: gpio
|
||||||
|
pin:
|
||||||
|
number: GPIO02
|
||||||
|
mode: INPUT_PULLUP
|
||||||
|
inverted: true
|
||||||
|
name: "${switch_2_name} Remote Switch"
|
||||||
|
id: light_button_2
|
||||||
|
filters:
|
||||||
|
- delayed_on: 20ms
|
||||||
|
on_click:
|
||||||
|
- min_length: 20ms
|
||||||
|
max_length: 500ms
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
if (id(relay2).state) {
|
||||||
|
// Relay is ON: turn it OFF
|
||||||
|
id(relay2).turn_off();
|
||||||
|
} else {
|
||||||
|
// Relay is OFF: turn it ON
|
||||||
|
id(relay2).turn_on();
|
||||||
|
}
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# STATUS LED
|
||||||
|
# https://esphome.io/components/status_led.html
|
||||||
|
##########################################################################################
|
||||||
|
# Sonoff Basic R1 LED is GPIO13
|
||||||
|
#############################################
|
||||||
|
status_led:
|
||||||
|
pin:
|
||||||
|
number: GPIO13
|
||||||
|
inverted: yes
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# MQTT COMMANDS
|
||||||
|
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||||
|
##########################################################################################
|
||||||
|
mqtt:
|
||||||
|
on_message:
|
||||||
|
# Relay 1 control
|
||||||
|
- topic: "${mqtt_main_topic}/relay1/set"
|
||||||
|
payload: "ON"
|
||||||
|
then:
|
||||||
|
- switch.turn_on: relay1
|
||||||
|
- topic: "${mqtt_main_topic}/relay1/set"
|
||||||
|
payload: "OFF"
|
||||||
|
then:
|
||||||
|
- switch.turn_off: relay1
|
||||||
|
|
Reference in New Issue
Block a user