diff --git a/esphome/common/network_common.yaml b/esphome/common/network_common.yaml index 7e2e8d5..92a359c 100644 --- a/esphome/common/network_common.yaml +++ b/esphome/common/network_common.yaml @@ -71,6 +71,7 @@ ota: - platform: esphome password: ${local_ota_pass} version: 2 + #- platform: web_server ############################################# # Safe Mode diff --git a/esphome/esp-centralstairs-bottom.yaml b/esphome/esp-centralstairs-bottom.yaml new file mode 100644 index 0000000..d1ad394 --- /dev/null +++ b/esphome/esp-centralstairs-bottom.yaml @@ -0,0 +1,248 @@ +########################################################################################## +########################################################################################## +# CENTRAL STAIRS - BOTTOM LIGHTSWITCH +# V3.7 2025-09-24 upload to this device +# V3.5 2025-07-24 YAML tidyups +########################################################################################## +# Zemismart KS-811 Double push button +# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/ +# +# NOTES +# - Light switch at top of the stairs, only the footer lights physically connected. +# +########################################################################################## +########################################################################################## + +########################################################################################## +# 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-centralstairs-bottom" + friendly_name: "Central Stair Lightswitch - Bottom (2)" + description_comment: "Central Stair Lightswitch - Bottom, using Zemismart KS-811 Double Push Button. Main Stair Lights (1), Stair Footer Lights (2)" + device_area: "" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. + + # Project Naming + project_name: "Zemismart Technologies.KS-811 Double" # Project Details + project_version: "v3.7" # Project V denotes release of yaml file, allowing checking of deployed vs latest version + + # Passwords & Secrets (unfortunately you can't use substitutions inside secrets names) + api_key: !secret esp-api_key + ota_pass: !secret esp-ota_pass + static_ip_address: !secret esp-centralstairs-bottom_ip + mqtt_command_main_topic: !secret mqtt_command_main_topic + mqtt_status_main_topic: !secret mqtt_status_main_topic + + # Device Settings + #relay_icon: "mdi:lightbulb-group" + log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE + update_interval: "60s" # update time for for general sensors etc + + # MQTT LOCAL Controls + mqtt_local_device_name: "stair-mainlights-lower" + mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_local_device_name}/set" # Topic we will use to command this locally without HA + mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_local_device_name}/state" # Topic we will use to view status locally without HA + mqtt_local_device_command_ON: "ON" + mqtt_local_device_command_OFF: "OFF" + + # MQTT REMOTE Controls + mqtt_remote_device1_name: "stair-footerlights" + mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}/set" + mqtt_remote_device1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device1_name}/state" + #mqtt_remote_device2_name: "stair-mainlights-upper" + #mqtt_remote_device2_command_topic: "${mqtt_local_command_main_topic}/${mqtt_remote_device2_name}/relay3/set" + #mqtt_remote_device2_status_topic: "${mqtt_local_status_main_topic}/${mqtt_remote_device2_name}/relay3/state" + mqtt_remote_device_command_ON: "ON" + mqtt_remote_device_command_OFF: "OFF" + + # Switch Naming + switch_1_name: "Main Stair Lights (Lower)" # Physical, but just the lower lights below the media cabinet + switch_2_name: "Stair Footer Lights" # virtual only, nothing connected to this output + #switch_3_name: "Nil" + +######################################################################################### +# PACKAGES: Included Common Packages +# https://esphome.io/components/packages.html +########################################################################################## +packages: + common_wifi: !include + file: common/network_common.yaml + vars: + local_device_name: "${device_name}" + 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 + vars: + local_device_name: "${device_name}" + 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}" + project: + name: "${project_name}" + version: "${project_version}" + #on_boot: + # priority: 200 + # then: + # - switch.turn_on: Relay_2 + +######################################################################################### +# ESP Platform and Framework +# https://esphome.io/components/esp32.html +######################################################################################### +esp8266: + board: esp01_1m + early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True. + board_flash_mode: dout # Default is dout + +######################################################################################### +# 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 + +########################################################################################## +# MQTT COMMANDS +# This adds device-specific MQTT command triggers to the common MQTT configuration. +########################################################################################## +mqtt: + on_connect: + then: + - if: + condition: + lambda: 'return id(Relay_1).state;' + then: + - mqtt.publish: + topic: "${mqtt_local_status_topic}" + payload: "${mqtt_local_device_command_ON}" + qos: 0 + retain: false + else: + - mqtt.publish: + topic: "${mqtt_local_status_topic}" + payload: "${mqtt_local_device_command_OFF}" + qos: 0 + retain: false + on_message: + # Light control to turn on relay 1 + - topic: "${mqtt_local_command_topic}" + payload: "${mqtt_local_device_command_ON}" + then: + - switch.turn_on: Relay_1 + # Light control to turn off relay 1 + - topic: "${mqtt_local_command_topic}" + payload: "${mqtt_local_device_command_OFF}" + then: + - switch.turn_off: Relay_1 + - topic: "${mqtt_remote_device1_status_topic}" + payload: "${mqtt_local_device_command_ON}" + then: + - switch.turn_on: Relay_2 + # Light control to turn off relay 2 + - topic: "${mqtt_remote_device1_status_topic}" + payload: "${mqtt_local_device_command_OFF}" + then: + - switch.turn_off: Relay_2 + +######################################################################################### +# STATUS LED +# https://esphome.io/components/status_led.html +######################################################################################### +status_led: + pin: + number: GPIO2 + inverted: yes + +######################################################################################### +# BINARY SENSORS +# https://esphome.io/components/binary_sensor/ +######################################################################################### +binary_sensor: + - platform: gpio + pin: + number: GPIO16 + mode: INPUT + inverted: True + filters: + - delayed_on: 30ms + - delayed_off: 30ms + name: "Button 1: ${switch_1_name}" + on_press: + - switch.toggle: Relay_1 + + - platform: gpio + pin: + number: GPIO05 + mode: INPUT + inverted: True + filters: + - delayed_on: 30ms + - delayed_off: 30ms + name: "Button 2: ${switch_2_name}" + on_press: + # Toggle the remote Footer Lights via COMMAND topic, based on our mirrored state + - if: + condition: + lambda: 'return id(Relay_2).state;' + then: + - mqtt.publish: + topic: "${mqtt_remote_device1_command_topic}" + payload: "${mqtt_remote_device_command_OFF}" + retain: false + else: + - mqtt.publish: + topic: "${mqtt_remote_device1_command_topic}" + payload: "${mqtt_remote_device_command_ON}" + retain: false + +######################################################################################### +# SWITCH COMPONENT +# https://esphome.io/components/switch/ +######################################################################################### +switch: + - platform: gpio + name: "Relay 1: ${switch_1_name}" + pin: GPIO13 + id: Relay_1 + on_turn_on: + - mqtt.publish: + topic: "${mqtt_local_status_topic}" + payload: "${mqtt_local_device_command_ON}" + retain: false + on_turn_off: + - mqtt.publish: + topic: "${mqtt_local_status_topic}" + payload: "${mqtt_local_device_command_OFF}" + retain: false + + - platform: gpio + name: "Relay 2: ${switch_2_name}" + pin: GPIO12 + id: Relay_2 + # No mqtt.publish here (this is a mirror only) diff --git a/esphome/esp-centralstairs-top.yaml b/esphome/esp-centralstairs-top.yaml new file mode 100644 index 0000000..7403e2f --- /dev/null +++ b/esphome/esp-centralstairs-top.yaml @@ -0,0 +1,232 @@ +########################################################################################## +########################################################################################## +# CENTRAL STAIRS - TOP LIGHTSWITCH +# V3.7 2025-09-24 upload to this device +# V3.5 2025-07-24 YAML tidyups +########################################################################################## +# Zemismart KS-811 Double push button +# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/ +# +# NOTES +# - Light switch at top of the stairs +# +########################################################################################## +########################################################################################## + +########################################################################################## +# 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-centralstairs-top" + friendly_name: "Central Stair Lightswitch - Top (2)" + description_comment: "Central Stair Lightswitch - Top, using Zemismart KS-811 Double Push Button. Main Stair Lights (1), Stair Footer Lights (2)" + device_area: "" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. + + # Project Naming + project_name: "Zemismart Technologies.KS-811 Double" # Project Details + project_version: "v3.7" # Project V denotes release of yaml file, allowing checking of deployed vs latest version + + # Passwords & Secrets (unfortunately you can't use substitutions inside secrets names) + api_key: !secret esp-api_key + ota_pass: !secret esp-ota_pass + static_ip_address: !secret esp-centralstairs-top_ip + mqtt_command_main_topic: !secret mqtt_command_main_topic + mqtt_status_main_topic: !secret mqtt_status_main_topic + + # Device Settings + #relay_icon: "mdi:lightbulb-group" + log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE + update_interval: "60s" # update time for for general sensors etc + + # MQTT LOCAL Controls + mqtt_local_device_name: "stair-footerlights" + mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_local_device_name}/set" # Topic we will use to command this locally without HA + mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_local_device_name}/state" # Topic we will use to view status locally without HA + mqtt_local_device_command_ON: "ON" + mqtt_local_device_command_OFF: "OFF" + + # MQTT REMOTE Controls + mqtt_remote_device1_name: "stair-mainlights-lower" + mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}/set" + mqtt_remote_device1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device1_name}/state" + #mqtt_remote_device2_name: "stair-mainlights-upper" + #mqtt_remote_device2_command_topic: "${mqtt_local_command_main_topic}/${mqtt_remote_device2_name}/relay3/set" + #mqtt_remote_device2_status_topic: "${mqtt_local_status_main_topic}/${mqtt_remote_device2_name}/relay3/state" + mqtt_remote_device_command_ON: "ON" + mqtt_remote_device_command_OFF: "OFF" + + # Switch Naming + switch_1_name: "Main Stair Lights" # virtual only, nothing connected to this output + switch_2_name: "Stair Footer Lights" + +######################################################################################### +# PACKAGES: Included Common Packages +# https://esphome.io/components/packages.html +########################################################################################## +packages: + common_wifi: !include + file: common/network_common.yaml + vars: + local_device_name: "${device_name}" + 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 + vars: + local_device_name: "${device_name}" + 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}" + project: + name: "${project_name}" + version: "${project_version}" + #on_boot: + # priority: 200 + # then: + # - switch.turn_on: Relay_2 + +######################################################################################### +# ESP Platform and Framework +# https://esphome.io/components/esp32.html +######################################################################################### +esp8266: + board: esp01_1m + early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True. + board_flash_mode: dout # Default is dout + +######################################################################################### +# 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 + +########################################################################################## +# MQTT COMMANDS +# This adds device-specific MQTT command triggers to the common MQTT configuration. +########################################################################################## +mqtt: + on_message: + # Light control to turn on relay 2 + - topic: "${mqtt_local_command_topic}" + payload: "${mqtt_local_device_command_ON}" + then: + - switch.turn_on: Relay_2 + # Light control to turn off relay 2 + - topic: "${mqtt_local_command_topic}" + payload: "${mqtt_local_device_command_OFF}" + then: + - switch.turn_off: Relay_2 + - topic: "${mqtt_remote_device1_status_topic}" + payload: "${mqtt_local_device_command_ON}" + then: + - switch.turn_on: Relay_1 + # Light control to turn off relay 2 + - topic: "${mqtt_remote_device1_status_topic}" + payload: "${mqtt_local_device_command_OFF}" + then: + - switch.turn_off: Relay_1 + +######################################################################################### +# STATUS LED +# https://esphome.io/components/status_led.html +######################################################################################### +status_led: + pin: + number: GPIO2 + inverted: yes + +######################################################################################### +# BINARY SENSORS +# https://esphome.io/components/binary_sensor/ +######################################################################################### +binary_sensor: + - platform: gpio + pin: + number: GPIO16 + mode: INPUT + inverted: True + filters: + - delayed_on: 30ms + - delayed_off: 30ms + name: "Button 1: ${switch_1_name}" + on_press: + # Toggle the remote Main Stair Lights (lower) via COMMAND topic, based on our mirrored state + - if: + condition: + lambda: 'return id(Relay_1).state;' + then: + - mqtt.publish: + topic: "${mqtt_remote_device1_command_topic}" + payload: "${mqtt_remote_device_command_OFF}" + retain: false + else: + - mqtt.publish: + topic: "${mqtt_remote_device1_command_topic}" + payload: "${mqtt_remote_device_command_ON}" + retain: false + + - platform: gpio + pin: + number: GPIO05 + mode: INPUT + inverted: True + filters: + - delayed_on: 30ms + - delayed_off: 30ms + name: "Button 2: ${switch_2_name}" + on_press: + - switch.toggle: Relay_2 + +######################################################################################### +# SWITCH COMPONENT +# https://esphome.io/components/switch/ +######################################################################################### +switch: + - platform: gpio + name: "Relay 1: ${switch_1_name}" + pin: GPIO13 + id: Relay_1 + # No mqtt.publish here (this is a mirror only) + + - platform: gpio + name: "Relay 2: ${switch_2_name}" + pin: GPIO12 + id: Relay_2 + on_turn_on: + - mqtt.publish: + topic: "${mqtt_local_status_topic}" + payload: "${mqtt_local_device_command_ON}" + retain: false + on_turn_off: + - mqtt.publish: + topic: "${mqtt_local_status_topic}" + payload: "${mqtt_local_device_command_OFF}" + retain: false + + diff --git a/esphome/esp-entmulti.yaml b/esphome/esp-entmulti.yaml index 5228ea1..229e2fa 100644 --- a/esphome/esp-entmulti.yaml +++ b/esphome/esp-entmulti.yaml @@ -287,21 +287,6 @@ sensor: # accuracy_decimals: 1 # oversampling: 2x - ################################ - # WIFI SIGNAL - # Quality of Wifi in dBm - # https://esphome.io/components/sensor/wifi_signal.html - ################################ - - platform: wifi_signal - name: ${friendly_name} WiFi Signal - update_interval: 20s - #retain: true #retain useful if sleeping - - - platform: uptime - name: ${friendly_name} Uptime - update_interval: 20s - - #The ld2410 sensor values - platform: ld2410 light: @@ -418,7 +403,7 @@ binary_sensor: number: GPIO13 mode: input: True - pullup: False + pullup: True inverted: True filters: - delayed_on: 50ms diff --git a/esphome/esp-entrancebathrmlights.yaml b/esphome/esp-entrancebathrmlights.yaml new file mode 100644 index 0000000..dd29caa --- /dev/null +++ b/esphome/esp-entrancebathrmlights.yaml @@ -0,0 +1,181 @@ +########################################################################################## +########################################################################################## +# ENTRANCE BATHROOM LIGHTSWITCH +# V3.7 2025-09-34 upload to this bathroom +# V3.5 2025-07-24 YAML tidyups +########################################################################################## +# Zemismart KS-811 Double push button +# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/ +# +# NOTES +# - Light switch with light and extract fan +# +########################################################################################## +########################################################################################## + +########################################################################################## +# 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-entrancebathrmlights" + friendly_name: "Entrance Bathroom Lightswitch (2)" + description_comment: "Entrance bathroom lightswitch using a Zemismart KS-811 Double Push Button. Main Lights (1), Extract Fan (2)" + device_area: "Entranceway" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant. + + # Project Naming + project_name: "Zemismart Technologies.KS-811 Double" # Project Details + project_version: "v3.5" # Project V denotes release of yaml file, allowing checking of deployed vs latest version + + # Passwords & Secrets + 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-entrancebathrmlights_ip + #mqtt_local_command_main_topic: !secret mqtt_local_command_main_topic + #mqtt_local_status_main_topic: !secret mqtt_local_status_main_topic + + # Device Settings + #relay_icon: "mdi:lightbulb-group" + log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE + update_interval: "60s" # update time for for general sensors etc + + # MQTT LOCAL Controls + #mqtt_device_name: "bedroom2-lights" + #mqtt_local_command_topic: "${mqtt_local_command_main_topic}/${mqtt_device_name}" # Topic we will use to command this locally without HA + #mqtt_local_status_topic: "${mqtt_local_status_main_topic}/${mqtt_device_name}" # Topic we will use to view status locally without HA + + # Switch Naming + switch_1_name: "Main Lights" + switch_2_name: "Extract Fan" + #switch_3_name: "Nil" + +######################################################################################### +# PACKAGES: Included Common Packages +# https://esphome.io/components/packages.html +########################################################################################## +packages: + common_wifi: !include + file: common/network_common.yaml + vars: + local_device_name: "${device_name}" + 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 + vars: + local_device_name: "${device_name}" + 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}" + project: + name: "${project_name}" + version: "${project_version}" + #on_boot: + # priority: 200 + # then: + # - switch.turn_on: Relay_2 + +######################################################################################### +# ESP Platform and Framework +# https://esphome.io/components/esp32.html +######################################################################################### +esp8266: + board: esp01_1m + early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True. + board_flash_mode: dout # Default is dout + +######################################################################################### +# 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 + +######################################################################################### +# STATUS LED +# https://esphome.io/components/status_led.html +######################################################################################### +status_led: + pin: + number: GPIO2 + inverted: yes + +######################################################################################### +# BINARY SENSORS +# https://esphome.io/components/binary_sensor/ +######################################################################################### +binary_sensor: + - platform: gpio + pin: + number: GPIO16 + mode: INPUT + inverted: True + name: "Button 1: ${switch_1_name}" + on_press: + - switch.toggle: Relay_1 + + - platform: gpio + pin: + number: GPIO05 + mode: INPUT + inverted: True + name: "Button 2: ${switch_2_name}" + on_press: + - switch.toggle: Relay_2 + +# KS-811-2 is a double only +# - platform: gpio +# pin: +# number: GPIO4 +# mode: INPUT +# inverted: True +# name: "Button 3: ${switch_3_name}" +# on_press: +# - switch.toggle: Relay_3 + +######################################################################################### +# SWITCH COMPONENT +# https://esphome.io/components/switch/ +######################################################################################### +switch: + - platform: gpio + name: "Relay 1: ${switch_1_name}" + pin: GPIO13 + id: Relay_1 + + - platform: gpio + name: "Relay 2: ${switch_2_name}" + pin: GPIO12 + id: Relay_2 + +# KS-811-2 is a double only +# - platform: gpio +# name: "Relay 3: ${switch_3_name}" +# pin: GPIO14 +# id: Relay_3 + + diff --git a/esphome/esp-occupancystair.yaml b/esphome/esp-occupancystair.yaml index 0ee3144..2679675 100644 --- a/esphome/esp-occupancystair.yaml +++ b/esphome/esp-occupancystair.yaml @@ -1,7 +1,8 @@ -############################################# -############################################# +########################################################################################## +########################################################################################## # HiLink LD2410 mmWave sensor, with BME280 Temp/Hum/Pres Sensor and PIR on an ESP32 # VERSION +# V2.1 2025-08-25 Added some MQTT to send commands to turn on remote lights # V2.0 2025-06-05 YAML Tidyups # # https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome/tree/main @@ -11,13 +12,13 @@ # https://www.simplysmart.house/blog/presence-detection-ld2410-home-assistant # # The B and C versions of this device can use Bluetooth, but we are not using it here. -############################################# -############################################# +########################################################################################## +########################################################################################## -############################################# +########################################################################################## # 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-occupancystair" @@ -27,21 +28,31 @@ substitutions: # Project Naming project_name: "Generic.ESP32" # Project Details - project_version: "v1.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version + project_version: "v2.1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version - # Passwords - api_key: !secret esp-occupancystair_api_key # unfortunately you can't use substitutions inside secrets names - ota_pass: !secret esp-occupancystair_ota_pass # unfortunately you can't use substitutions inside secrets names + # Passwords & Secrets (unfortunately you can't use substitutions inside secrets names) + api_key: !secret esp-api_key + ota_pass: !secret esp-ota_pass static_ip_address: !secret esp-occupancystair_ip - + mqtt_command_main_topic: !secret mqtt_command_main_topic + mqtt_status_main_topic: !secret mqtt_status_main_topic + # Device Settings + #relay_icon: "mdi:lightbulb-group" log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE update_interval: "60s" # update time for for general sensors etc + + # MQTT REMOTE Controls + mqtt_remote_device1_name: "stair-footerlights" + mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}/set" + #mqtt_remote_device1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device1_name}/state" + mqtt_remote_device_command_ON: "ON" + mqtt_remote_device_command_OFF: "OFF" -############################################# -# Included Common Packages -# https://esphome.io/components/esphome.html -############################################# +######################################################################################### +# PACKAGES: Included Common Packages +# https://esphome.io/components/packages.html +########################################################################################## packages: common_wifi: !include file: common/network_common.yaml @@ -67,10 +78,10 @@ packages: local_friendly_name: "${friendly_name}" local_update_interval: "${update_interval}" -############################################# -# ESPHome +########################################################################################## +# ESPHome CORE CONFIGURATION # https://esphome.io/components/esphome.html -############################################# +########################################################################################## esphome: name: "${device_name}" friendly_name: "${friendly_name}" @@ -81,55 +92,67 @@ esphome: #priority: -200 #then: -############################################# -# ESP Platform and Framework +########################################################################################## +# ESP PLATFORM AND FRAMEWORK +# https://esphome.io/components/esp8266.html # https://esphome.io/components/esp32.html -############################################# +########################################################################################## esp32: board: esp32dev framework: type: esp-idf # "esp-idf" OR "arduino". Suggested ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang. version: recommended # recommended, latest or dev -############################################# -# i2s bus +########################################################################################## +# GLOBAL VARIABLES +# https://esphome.io/components/globals.html +########################################################################################## +globals: + - id: stair_footer_auto_default_s + type: int + restore_value: yes + initial_value: '20' + +########################################################################################## +# i2c BUS COMPONENT # https://esphome.io/components/i2c.html -############################################# +########################################################################################## i2c: sda: GPIO19 scl: GPIO21 scan: True frequency: 100kHz #10, 50, 100, 200, 800 are possible settings, 100kHz was reliable for me -############################################# -# ESPHome Logging Enable +########################################################################################## +# LOGGER COMPONENT # https://esphome.io/components/logger.html -############################################# +# Logs all log messages through the serial port and through MQTT topics. +########################################################################################## logger: level: INFO # 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 -############################################# -# Bluetooth -# https://esphome.io/components/bluetooth_proxy.html -# https://esphome.io/components/esp32_ble_tracker.html +########################################################################################## +# BLUETOOTH +# Proxy https://esphome.io/components/bluetooth_proxy.html +# BLE https://esphome.io/components/esp32_ble_tracker.html # Remember that this takes a LOT of processing. On the # ESP32, enable the IDF framework, and disable the # Web server component. Changing to the IDF framework # needs to be via cable not OTA to change the # partition setup. -############################################# +########################################################################################## #bluetooth_proxy: #esp32_ble_tracker: -############################################# -# UART Serial -# hardware on EPS32, but software, and can be glitchy on ESP8266 -# https://esphome.io/components/uart.html?highlight=uart -############################################# +########################################################################################## +# UART BUS +# hardware on EPS32, but software (and can be glitchy) on ESP8266 +# https://esphome.io/components/uart.html +########################################################################################## uart: id: ld2410_uart rx_pin: GPIO16 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang @@ -139,21 +162,23 @@ uart: stop_bits: 1 parity: NONE -############################################# -# General esp status LED +######################################################################################### +# STATUS LED # https://esphome.io/components/status_led.html -############################################# +######################################################################################### +# ESP32 D1 Mini Board: Onboard Status LED on GPIO2, active-low +######################################################################################### status_led: pin: - number: GPIO2 #ESP32 Onboard LED + number: GPIO2 # ESP32 Onboard LED ignore_strapping_warning: True #https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins inverted: false -############################################# +########################################################################################## # LD2410 Sensors # https://esphome.io/components/sensor/ld2410.html # https://www.hlktech.net/index.php?id=988 -############################################# +########################################################################################## ld2410: uart_id: ld2410_uart #uart_id (Optional, ID): Manually specify the ID of the UART Component if you want to use multiple UART buses. @@ -171,6 +196,11 @@ ld2410: #still_energy (Optional, int): When in engineering mode, the still energy of the gate, otherwise unknown. Value between 0 and 100 inclusive. All options from Sensor. #ld2410_id (Optional, ID): Manually specify the ID for the LD2410 Sensor component if you are using multiple components. + +########################################################################################## +# NUMBER COMPONENT +# https://esphome.io/components/number/ +########################################################################################## #The ld2410 number values for setting thresholds # timeout: 5s # max_move_distance: 2.25m @@ -249,12 +279,34 @@ number: still_threshold: name: "g8 still threshold" -#The ld2410 select allows you to control your LD2410 Sensor. -#distance_resolution (Optional): Control the gates distance resolution. Can be 0.75m or 0.2m. Defaults to 0.75m. All options from Select. -#baud_rate (Optional): Control the serial port baud rate. Defaults to 256000. Once changed, all sensors will stop working until a fresh install with an updated UART Component configuration. All options from Select. -#light_function (Optional): If set, will affect the OUT pin value, based on light threshold. Can be off, low or above. Defaults to off. All options from Select. -#out_pin_level (Optional): Control OUT pin away value. Can be low or high. Defaults to low. All options from Select. -#ld2410_id (Optional, ID): Manually specify the ID for the LD2410 Sensor component if you are using multiple components. + - platform: template + id: stair_footer_auto_time_s + name: "Stair Footer Lights Auto Time" + unit_of_measurement: s + min_value: 10 + max_value: 300 + step: 1 + optimistic: true + restore_value: true + initial_value: 20 + +######################################################################################### +# SELECT COMPONENT +# https://esphome.io/components/select/index.html +######################################################################################### +# LD2410 SELECT +# distance_resolution (Optional): Control the gates distance resolution. Can be 0.75m or 0.2m. +# Defaults to 0.75m. All options from Select. +# baud_rate (Optional): Control the serial port baud rate. Defaults to 256000. Once changed, +# all sensors will stop working until a fresh install with an updated UART Component +# configuration. All options from Select. +# light_function (Optional): If set, will affect the OUT pin value, based on light +# threshold. Can be off, low or above. Defaults to off. All options from Select. +# out_pin_level (Optional): Control OUT pin away value. Can be low or high. Defaults +# to low. All options from Select. +# ld2410_id (Optional, ID): Manually specify the ID for the LD2410 Sensor component +# if you are using multiple components. +######################################################################################### select: - platform: ld2410 distance_resolution: @@ -266,10 +318,10 @@ select: out_pin_level: name: "${friendly_name} LD2140 Out Pin Level" -############################################# -# General Sensors -# https://esphome.io/components/sensor/index.html -############################################# +########################################################################################## +# SENSOR COMPONENT +# https://esphome.io/components/sensor/ +########################################################################################## sensor: - platform: bme280_i2c temperature: @@ -286,7 +338,8 @@ sensor: address: 0x76 update_interval: "${update_interval}" -#The ld2410 sensor values + # The ld2410 sensor values + # https://esphome.io/components/sensor/ld2410/#sensor - platform: ld2410 light: name: "Light" @@ -346,29 +399,59 @@ sensor: still_energy: name: "g8 still energy" +########################################################################################## +# SWITCH COMPONENT +# https://esphome.io/components/switch/ +########################################################################################## # The ld2410 switch allows you to control your LD2410 Sensor. -#Bluetooth switch is only useful of you have a B or C model +# Bluetooth switch is only useful of you have a B or C model +########################################################################################## switch: + # https://esphome.io/components/sensor/ld2410/#switch - platform: ld2410 engineering_mode: name: "${friendly_name} LD2140 Engineering Mode" #bluetooth: #name: "${friendly_name} LD2140 Control Bluetooth" -#The ld2410 binary sensors to get presence notification + - platform: template + id: stair_footer_auto_enabled + name: "Stair Footer Lights Auto" + optimistic: true + restore_mode: RESTORE_DEFAULT_ON + +######################################################################################### +# BINARY SENSORS +# https://esphome.io/components/binary_sensor/ +######################################################################################### binary_sensor: + # The ld2410 binary sensors to get presence notification + # https://esphome.io/components/sensor/ld2410/#binary-sensor - platform: ld2410 has_target: name: "mmWave Presence" + on_press: + - if: + condition: + switch.is_on: stair_footer_auto_enabled + then: + - script.execute: stair_footer_auto_script has_moving_target: name: "mmWave Moving Target" + on_press: + - if: + condition: + switch.is_on: stair_footer_auto_enabled + then: + - script.execute: stair_footer_auto_script has_still_target: name: "mmWave Still Target" out_pin_presence_status: name: "LD2140 Out Pin Presence Status" entity_category: diagnostic -#Standard PIR Sensor +# Generic PIR Sensor +# https://devices.esphome.io/devices/Generic-PIR - platform: gpio pin: number: GPIO13 @@ -378,8 +461,21 @@ binary_sensor: inverted: true name: "PIR Sensor" device_class: motion + filters: + - delayed_on: 50ms + on_press: + - if: + condition: + switch.is_on: stair_footer_auto_enabled + then: + - script.execute: stair_footer_auto_script -#The ld2410 button allows resetting +################################################################################################# +# BUTTON COMPONENT +# https://esphome.io/components/button/index.html +################################################################################################# +# The ld2410 button allows resetting +################################################################################################# button: - platform: ld2410 factory_reset: @@ -389,13 +485,41 @@ button: query_params: name: "Query Parameters" -#The ld2410 text sensor allows you to get information about your LD2410 Sensor. -#Bluetooth sensor is only useful of you have a B or C model +################################################################################################# +# TEXT SENSOR COMPONENT +# https://esphome.io/components/text_sensor/ +################################################################################################# text_sensor: + # The ld2410 text sensor allows you to get information about your LD2410 Sensor. + # Bluetooth sensor is only useful of you have a B or C model + # https://esphome.io/components/sensor/ld2410/#text-sensor - platform: ld2410 version: name: "${friendly_name} LD2140 Firmware Version" #mac_address: #name: "${friendly_name} LD2140 BT MAC Address" +########################################################################################## +# SCRIPT COMPONENT +# https://esphome.io/components/script.html +# Scripts can be executed nearly anywhere in your device configuration with a single call. +########################################################################################## +script: + # Sends commands to turn on and off a remote light + - id: stair_footer_auto_script + mode: restart + then: + # Turn lights on (command the Top switch's footer relay) + - mqtt.publish: + topic: "${mqtt_remote_device1_command_topic}" + payload: "${mqtt_remote_device_command_ON}" + retain: false + # Wait for the HA-adjustable timeout + - delay: !lambda 'return (uint32_t)(id(stair_footer_auto_time_s).state) * 1000;' + + # Turn lights back off + - mqtt.publish: + topic: "${mqtt_remote_device1_command_topic}" + payload: "${mqtt_remote_device_command_OFF}" + retain: false diff --git a/packages/health_checks.yaml b/packages/health_checks.yaml index d6b4ed4..7196393 100644 --- a/packages/health_checks.yaml +++ b/packages/health_checks.yaml @@ -20,17 +20,17 @@ mqtt: device_class: connectivity qos: 1 # Optional: avoid stale 'online' if no updates arrive - expire_after: 300 + expire_after: 180 # ---- Combine them (true if either is up) ---- template: - binary_sensor: - - name: "Node-RED Panda Up" + - name: "Node-RED Panda Up (HTTP/MQTT)" unique_id: "nodered_panda_up_combined" device_class: connectivity state: > {{ is_state('binary_sensor.node_red_panda_up_http','on') - or is_state('binary_sensor.node_red_panda_up_mqtt','on') }} + or is_state('binary_sensor.node_red_panda_up_mqtt','on') }} availability: > {{ states('binary_sensor.node_red_panda_up_http') not in ['unknown','unavailable'] - or states('binary_sensor.node_red_panda_up_mqtt') not in ['unknown','unavailable'] }} + or states('binary_sensor.node_red_panda_up_mqtt') not in ['unknown','unavailable'] }} diff --git a/packages/openbeken.yaml b/packages/openbeken.yaml index e168059..20c708d 100644 --- a/packages/openbeken.yaml +++ b/packages/openbeken.yaml @@ -1,5 +1,5 @@ mqtt: - switch: + switch: - unique_id: "Garage_Entry_Switch_1" name: "Garage Entry Switch 1" state_topic: "obk/obk-ks811t-006D-garageentry/1/get" @@ -30,33 +30,33 @@ mqtt: retain: true availability: - topic: "obk/obk-ks811t-006D-garageentry/connected" - - unique_id: "Main_Bathroom_Light_Switch_1" - name: "Main Bathroom Light Switch 1" - state_topic: "obk/obk-ks811t-B1C4-mainbath1/1/get" - command_topic: "obk/obk-ks811t-B1C4-mainbath1/1/set" - qos: 1 - payload_on: 1 - payload_off: 0 - retain: true - availability: - - topic: "obk/obk-ks811t-B1C4-mainbath1/connected" - - unique_id: "Main_Bathroom_Light_Switch_2" - name: "Main Bathroom Light Switch 2" - state_topic: "obk/obk-ks811t-B1C4-mainbath1/2/get" - command_topic: "obk/obk-ks811t-B1C4-mainbath1/2/set" - qos: 1 - payload_on: 1 - payload_off: 0 - retain: true - availability: - - topic: "obk/obk-ks811t-B1C4-mainbath1/connected" - - unique_id: "Main_Bathroom_Light_Switch_3" - name: "Main Bathroom Light Switch 3" - state_topic: "obk/obk-ks811t-B1C4-mainbath1/3/get" - command_topic: "obk/obk-ks811t-B1C4-mainbath1/3/set" - qos: 1 - payload_on: 1 - payload_off: 0 - retain: true - availability: - - topic: "obk/obk-ks811t-B1C4-mainbath1/connected" +# - unique_id: "Main_Bathroom_Light_Switch_1" +# name: "Main Bathroom Light Switch 1" +# state_topic: "obk/obk-ks811t-B1C4-mainbath1/1/get" +# command_topic: "obk/obk-ks811t-B1C4-mainbath1/1/set" +# qos: 1 +# payload_on: 1 +# payload_off: 0 +# retain: true +# availability: +# - topic: "obk/obk-ks811t-B1C4-mainbath1/connected" +# - unique_id: "Main_Bathroom_Light_Switch_2" +# name: "Main Bathroom Light Switch 2" +# state_topic: "obk/obk-ks811t-B1C4-mainbath1/2/get" +# command_topic: "obk/obk-ks811t-B1C4-mainbath1/2/set" +# qos: 1 +# payload_on: 1 +# payload_off: 0 +# retain: true +# availability: +# - topic: "obk/obk-ks811t-B1C4-mainbath1/connected" +# - unique_id: "Main_Bathroom_Light_Switch_3" +# name: "Main Bathroom Light Switch 3" +# state_topic: "obk/obk-ks811t-B1C4-mainbath1/3/get" +# command_topic: "obk/obk-ks811t-B1C4-mainbath1/3/set" +# qos: 1 +# payload_on: 1 +# payload_off: 0 +# retain: true +# availability: +# - topic: "obk/obk-ks811t-B1C4-mainbath1/connected" diff --git a/packages/simulation_lights.yaml b/packages/simulation_lights.yaml index ec39329..f482b2c 100644 --- a/packages/simulation_lights.yaml +++ b/packages/simulation_lights.yaml @@ -3,7 +3,6 @@ group: name: Simulation Lights (All) entities: - switch.tasmo_ks811d_1242_entrance_a - - switch.tasmo_ks811d_0302_entrybath_a - switch.tasmo_ks811d_6110_kitchen_a - switch.tasmo_ks811d_6110_kitchen_b - switch.main_hallway_lightswitch_tasmo_ks811s_2940_hallway_1a @@ -11,4 +10,5 @@ group: - switch.tasmo_ks811t_0702_lounge_3a - switch.tasmo_ks811t_0702_lounge_3b - switch.tasmo_ks811t_0702_lounge_3c + - switch.esp_entrancebathrmlights_relay_1_main_lights - group.downstairs_flat_lights # ← now valid here