various esphome devices updates
This commit is contained in:
@@ -16,7 +16,6 @@ substitutions:
|
||||
# Device Naming
|
||||
device_name: "esp-officeelvcontrol"
|
||||
friendly_name: "Office ELV Control"
|
||||
mqtt_device_name: "office-elv-control"
|
||||
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.
|
||||
|
||||
@@ -35,12 +34,13 @@ substitutions:
|
||||
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: "Office ELV Power Supply"
|
||||
button_1_name: "Power Button"
|
||||
|
||||
# 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_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"
|
||||
mqtt_device_name: "office-elv-control"
|
||||
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
|
||||
@@ -84,7 +84,6 @@ esphome:
|
||||
# - "-fno-exceptions" # strip C++ exceptions
|
||||
# - "-fno-rtti" # strip C++ RTTI
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# ESP Platform and Framework
|
||||
# https://esphome.io/components/esp32.html
|
||||
@@ -117,17 +116,17 @@ logger:
|
||||
#############################################
|
||||
switch:
|
||||
- platform: gpio
|
||||
name: "ELV Power Supply"
|
||||
name: "${relay_1_name}"
|
||||
pin: GPIO12
|
||||
id: relay
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
id: relay1
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
icon: "${relay_icon}"
|
||||
|
||||
##########################################################################################
|
||||
# BINARY SENSORS
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
##########################################################################################
|
||||
# Sonoff Basic R1 Button is GPIO03
|
||||
# Sonoff Basic R1 Button is GPIO03
|
||||
#############################################
|
||||
binary_sensor:
|
||||
|
||||
@@ -136,7 +135,7 @@ binary_sensor:
|
||||
number: GPIO03
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
name: "Power Button"
|
||||
name: "${button_1_name}"
|
||||
id: power_button
|
||||
filters:
|
||||
- delayed_on: 20ms
|
||||
@@ -145,19 +144,27 @@ binary_sensor:
|
||||
max_length: 500ms
|
||||
then:
|
||||
- lambda: |-
|
||||
if (id(relay).state) {
|
||||
if (id(relay1).state) {
|
||||
// Relay is ON: turn it OFF
|
||||
id(relay).turn_off();
|
||||
id(relay1).turn_off();
|
||||
} else {
|
||||
// Relay is OFF: turn it ON
|
||||
id(relay).turn_on();
|
||||
id(relay1).turn_on();
|
||||
}
|
||||
|
||||
# Mimics actual relay status (but not controllable)
|
||||
- platform: template
|
||||
name: "Relay Status"
|
||||
name: "${relay_1_name} Status"
|
||||
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
|
||||
@@ -171,22 +178,18 @@ status_led:
|
||||
inverted: yes
|
||||
|
||||
##########################################################################################
|
||||
# Text Sensors
|
||||
# https://esphome.io/components/text_sensor/index.html
|
||||
# MQTT COMMANDS
|
||||
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||
##########################################################################################
|
||||
text_sensor:
|
||||
- platform: mqtt_subscribe
|
||||
name: "Office ELV MQTT Command"
|
||||
id: office_elv_cmd
|
||||
topic: "${mqtt_command_topic}"
|
||||
internal: true # hide from HA
|
||||
on_value:
|
||||
mqtt:
|
||||
on_message:
|
||||
# Relay 1 control
|
||||
- topic: "${mqtt_main_topic}/relay1/set"
|
||||
payload: "ON"
|
||||
then:
|
||||
- lambda: |-
|
||||
// payload is x (std::string)
|
||||
if (x == "ON") {
|
||||
id(relay).turn_on();
|
||||
} else if (x == "OFF") {
|
||||
id(relay).turn_off();
|
||||
}
|
||||
- switch.turn_on: relay1
|
||||
- topic: "${mqtt_main_topic}/relay1/set"
|
||||
payload: "OFF"
|
||||
then:
|
||||
- switch.turn_off: relay1
|
||||
|
||||
|
Reference in New Issue
Block a user