initial push

This commit is contained in:
CeeWeasel
2024-04-14 14:08:56 -04:00
commit 53bf393d14
1111 changed files with 71730 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
**/.pioenvs/
**/.piolibdeps/
**/lib/
**/src/
**/platformio.ini
/secrets.yaml
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
substitutions:
devicename: black-bed
friendly_name: Black Bed
entity_name: black_bed
platform: ESP8266
board: nodemcuv2
static_ip: !secret black-bed-ip
dout_pin: !secret black-bed-dout
clk_pin: !secret black-bed-clk
loadcell_zero: !secret black-bed-zero
loadcell_load: !secret black-bed-load
loadcell_weight: !secret black-bed-weight
# Enable logging
logger:
level: DEBUG
logs:
sensor: INFO
hx711: INFO
packages:
wifi: !include common/wifi.yaml
device_base: !include common/device_base.yaml
hx711: !include common/hx711_single_verbose.yaml
@@ -0,0 +1,3 @@
platform: status
name: "${friendly_name} Status"
id: ${entity_name}_status
+3
View File
@@ -0,0 +1,3 @@
esp32_ble_beacon:
type: iBeacon
uuid: ${uuid}
+8
View File
@@ -0,0 +1,8 @@
esp32_ble_tracker:
scan_parameters:
interval: 1100ms
window: 1100ms
active: true
bluetooth_proxy:
active: true
+8
View File
@@ -0,0 +1,8 @@
esp32_ble_tracker:
binary_sensor:
- platform: ble_presence
ibeacon_uuid: '601c742f-2b19-ed3c-f5fc-0bb31d6c2eac'
ibeacon_major: 100
ibeacon_minor: 1
name: "${friendly_name} Pixel 4"
+5
View File
@@ -0,0 +1,5 @@
esp32_ble_tracker:
esp32_ble_beacon:
type: iBeacon
uuid: ${uuid}
@@ -0,0 +1,4 @@
platform: restart
name: "${friendly_name} Restart"
id: ${entity_name}_restart
disabled_by_default: false
+38
View File
@@ -0,0 +1,38 @@
esp32:
board: nodemcu-32s
variant: esp32
framework:
type: arduino
version: 2.0.2
source: https://github.com/espressif/arduino-esp32.git#2.0.2
platform_version: https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
esphome:
platformio_options:
build_flags:
- -DCONFIG_ARDUINO_LOOP_STACK_SIZE=32768
name: ${devicename}
# Enable logging
logger:
# Time is managed via SNTP
# Enable Home Assistant API
api:
reboot_timeout: 15min
ota:
binary_sensor:
- <<: !include binary_sensor/status_sensor.config.yaml
button:
- <<: !include button/restart_button.config.yaml
sensor:
- <<: !include sensor/uptime_sensor.config.yaml
#text_sensor:
# - <<: !include text_sensor/version_sensor.config.yaml
+30
View File
@@ -0,0 +1,30 @@
esphome:
name: ${devicename}
platform: ${platform}
board: ${board}
# Enable logging
logger:
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
# Enable Home Assistant API
api:
reboot_timeout: 15min
ota:
binary_sensor:
- <<: !include binary_sensor/status_sensor.config.yaml
button:
- <<: !include button/restart_button.config.yaml
sensor:
- <<: !include sensor/uptime_sensor.config.yaml
#text_sensor:
# - <<: !include text_sensor/version_sensor.config.yaml
+18
View File
@@ -0,0 +1,18 @@
ethernet:
id: eth
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
power_pin: GPIO5
manual_ip:
static_ip: ${static_ip}
gateway: !secret iot_default_gateway
subnet: !secret iot_subnet_mask
dns1: !secret iot_default_dns1
#text_sensor:
#- <<: !include text_sensor/ethernet_ip_address.config.yaml
#- <<: !include text_sensor/ethernet_mac_address.config.yaml
+371
View File
@@ -0,0 +1,371 @@
globals:
- id: left_initial_zero
type: float
restore_value: yes
# NOTE: make sure to align this value to the one used in "calibrate_linear" below!
initial_value: ${left_loadcell_zero}
- id: right_initial_zero
type: float
restore_value: yes
# NOTE: make sure to align this value to the one used in "calibrate_linear" below!
initial_value: ${right_loadcell_zero}
- id: left_auto_tare_difference
type: float
restore_value: yes
initial_value: '0'
- id: right_auto_tare_difference
type: float
restore_value: yes
initial_value: '0'
- id: left_manual_tare_flag
type: bool
restore_value: no
initial_value: 'false'
- id: right_manual_tare_flag
type: bool
restore_value: no
initial_value: 'false'
- id: auto_tare_enabled
type: bool
restore_value: yes
initial_value: 'true'
- id: occupancy_forced
type: bool
restore_value: yes
initial_value: 'false'
sensor:
- platform: homeassistant
entity_id: input_number.${entity_name}_left_occupied
internal: true
id: left_occupied
- platform: homeassistant
entity_id: input_number.${entity_name}_right_occupied
internal: true
id: right_occupied
- platform: template
name: "${friendly_name} Left Raw Value"
lambda: |-
return id(hx711_left_value_raw).raw_state;
unit_of_measurement: w
update_interval: 1s
state_class: measurement
disabled_by_default: true
- platform: template
name: "${friendly_name} Right Raw Value"
lambda: |-
return id(hx711_right_value_raw).raw_state;
unit_of_measurement: w
update_interval: 1s
state_class: measurement
disabled_by_default: true
- platform: template
name: "${friendly_name} Left Auto Tare"
lambda: |-
return id(left_auto_tare_difference);
unit_of_measurement: w
update_interval: 1s
state_class: measurement
disabled_by_default: true
- platform: template
name: "${friendly_name} Right Auto Tare"
lambda: |-
return id(right_auto_tare_difference);
unit_of_measurement: w
update_interval: 1s
state_class: measurement
disabled_by_default: true
- platform: template
name: "${friendly_name} Left Initial Zero"
lambda: |-
return id(left_initial_zero);
unit_of_measurement: w
state_class: measurement
update_interval: 60s
disabled_by_default: true
- platform: template
name: "${friendly_name} Right Initial Zero"
lambda: |-
return id(right_initial_zero);
unit_of_measurement: w
state_class: measurement
update_interval: 60s
disabled_by_default: true
# Left RAW Scale input
- platform: hx711
id: hx711_left_value_raw
internal: True
dout_pin: ${left_dout_pin}
clk_pin: ${left_clk_pin}
gain: 128
accuracy_decimals: 3
update_interval: 0.2s
filters:
- lambda: !lambda |-
if (x > 8388000.0) return {};
if (x < -8388000.0) return {};
return x;
- sliding_window_moving_average:
window_size: 3
send_every: 1
on_value:
then:
- sensor.template.publish:
id: hx711_left_value
state: !lambda 'return id(hx711_left_value_raw).state;'
- if:
condition:
and:
- lambda: 'return id(auto_tare_enabled);'
# current smart scale value is below approx. 10KG (raw value -375000 aka nobody is standing on the scale
- lambda: 'return id(hx711_left_value).state < 10.0;'
then:
- if:
condition:
# current raw scale value is below expected zero value
- lambda: 'return id(hx711_left_value_raw).state < (id(left_initial_zero) - id(left_auto_tare_difference));'
then:
# INcrease Auto-Tare offset to slowly align real zero value with expected zero value
- lambda: |-
id(left_auto_tare_difference) += 10;
else:
# DEcrease Auto-Tare offset to slowly align real zero value with expected zero value
- lambda: |-
id(left_auto_tare_difference) -= 10;
# Right RAW Scale input
- platform: hx711
id: hx711_right_value_raw
internal: True
dout_pin: ${right_dout_pin}
clk_pin: ${right_clk_pin}
gain: 128
accuracy_decimals: 3
update_interval: 0.2s
filters:
- lambda: !lambda |-
if (x > 8388000.0) return {};
if (x < -8388000.0) return {};
return x;
- sliding_window_moving_average:
window_size: 3
send_every: 1
on_value:
then:
- sensor.template.publish:
id: hx711_right_value
state: !lambda 'return id(hx711_right_value_raw).state;'
- if:
condition:
and:
- lambda: 'return id(auto_tare_enabled);'
# current smart scale value is below approx. 10KG (raw value -375000 aka nobody is standing on the scale
- lambda: 'return id(hx711_right_value).state < 10.0;'
then:
- if:
condition:
# current raw scale value is below expected zero value
- lambda: 'return id(hx711_right_value_raw).state < (id(right_initial_zero) - id(right_auto_tare_difference));'
then:
# INcrease Auto-Tare offset to slowly align real zero value with expected zero value
- lambda: |-
id(right_auto_tare_difference) += 10;
else:
# DEcrease Auto-Tare offset to slowly align real zero value with expected zero value
- lambda: |-
id(right_auto_tare_difference) -= 10;
# Left Mapped value to lbs
- platform: template
id: hx711_left_value
name: "${friendly_name} Left Weight"
internal: False
filters:
# apply auto_tare difference
- lambda: 'return x + id(left_auto_tare_difference);'
# apply rough calibration
- calibrate_linear:
# retrieve these values by evaluating the raw values with loads of known mass.
# note that a bigger difference between measurements usually results in higher resolution,
# so measure 0 Kg and the highest known mass you have (like f.ex. your own weight, measured by a normal scale with good accuracy)
# 1221300 difference between the two
# was at -23800 for the longest time
- ${left_loadcell_zero} -> 0
- ${left_loadcell_load} -> ${left_loadcell_weight}
# map values below 0.1 to 0 (to decrease value changes due to random fluctuation)
- lambda: |-
if (x <= 0.1 || id(hx711_left_error).state) {
return 0.0;
} else {
return x;
}
unit_of_measurement: lbs
accuracy_decimals: 0
update_interval: 0.5s
state_class: measurement
# Right Mapped value to lbs
- platform: template
id: hx711_right_value
name: "${friendly_name} Right Weight"
internal: False
filters:
# apply auto_tare difference
- lambda: 'return x + id(right_auto_tare_difference);'
# apply rough calibration
- calibrate_linear:
# retrieve these values by evaluating the raw values with loads of known mass.
# note that a bigger difference between measurements usually results in higher resolution,
# so measure 0 Kg and the highest known mass you have (like f.ex. your own weight, measured by a normal scale with good accuracy)
# 1221300 difference between the two
# was at -23800 for the longest time
- ${right_loadcell_zero} -> 0
- ${right_loadcell_load} -> ${right_loadcell_weight}
# map values below 0.1 to 0 (to decrease value changes due to random fluctuation)
- lambda: |-
if (x <= 0.1 || id(hx711_right_error).state) {
return 0.0;
} else {
return x;
}
unit_of_measurement: lbs
accuracy_decimals: 0
update_interval: 0.5s
state_class: measurement
- platform: template
name: "${friendly_name} Combined"
id: combined_weight
update_interval: 1s
unit_of_measurement: lbs
state_class: measurement
lambda: |-
return id(hx711_left_value).state + id(hx711_right_value).state;
binary_sensor:
- platform: template
name: "${friendly_name} Left Occupied"
id: is_left_occupied
lambda: |-
if (
id(hx711_left_value).state >= id(left_occupied).state
) {
return true;
} else {
return false;
}
- platform: template
name: "${friendly_name} Right Occupied"
id: is_right_occupied
lambda: |-
if (
id(hx711_right_value).state >= id(right_occupied).state
) {
return true;
} else {
return false;
}
- platform: template
name: "${friendly_name} Occupied"
lambda: |-
if ( id(is_left_occupied).state || id(is_right_occupied).state )
{
return true;
} else {
return false;
}
- platform: template
name: "${friendly_name} Left HX711 Error"
id: hx711_left_error
device_class: problem
lambda: |-
if (
id(hx711_left_value_raw).raw_state > 8388000.0 || id(hx711_left_value_raw).raw_state < -8388000.0
) {
return true;
} else {
return false;
}
- platform: template
name: "${friendly_name} Right HX711 Error"
id: hx711_right_error
device_class: problem
lambda: |-
if (
id(hx711_right_value_raw).raw_state > 8388000.0 || id(hx711_right_value_raw).raw_state < -8388000.0
) {
return true;
} else {
return false;
}
- platform: template
name: "${friendly_name} HX711 Error"
id: hx711_error
device_class: problem
lambda: |-
if (
id(hx711_left_error).state || id(hx711_right_error).state
) {
return true;
} else {
return false;
}
switch:
- platform: template
id: auto_tare
name: "${friendly_name} Auto Tare"
lambda: |-
return id(auto_tare_enabled);
turn_on_action:
- lambda: |-
id(auto_tare_enabled) = true;
turn_off_action:
- lambda: |-
id(auto_tare_enabled) = false;
- platform: template
id: left_manual_tare
name: "${friendly_name} Left Manual Tare"
lambda: |-
return id(left_manual_tare_flag);
turn_on_action:
- lambda: |-
id(left_auto_tare_difference) = id(left_initial_zero) - id(hx711_left_value_raw).state;
- switch.turn_off: left_manual_tare
turn_off_action:
- lambda: |-
id(left_manual_tare_flag) = false;
- platform: template
id: right_manual_tare
name: "${friendly_name} Right Manual Tare"
lambda: |-
return id(right_manual_tare_flag);
turn_on_action:
- lambda: |-
id(right_auto_tare_difference) = id(right_initial_zero) - id(hx711_right_value_raw).state;
- switch.turn_off: right_manual_tare
turn_off_action:
- lambda: |-
id(right_manual_tare_flag) = false;
+205
View File
@@ -0,0 +1,205 @@
globals:
- id: initial_zero
type: float
restore_value: yes
# NOTE: make sure to align this value to the one used in "calibrate_linear" below!
initial_value: ${loadcell_zero}
- id: auto_tare_enabled
type: bool
restore_value: yes
initial_value: 'true'
- id: auto_tare_difference
type: float
restore_value: yes
initial_value: '0'
- id: occupancy_forced
type: bool
restore_value: no
initial_value: 'false'
sensor:
- platform: homeassistant
entity_id: input_number.${entity_name}_occupied
internal: true
id: occupied
- platform: template
internal: false
name: "${friendly_name} Raw Value"
lambda: |-
return id(hx711_value_raw).raw_state;
filters:
- filter_out: nan
- throttle_average: 30s
- heartbeat: 60s
- delta: 1000
unit_of_measurement: w
update_interval: 1s
state_class: measurement
disabled_by_default: true
icon: mdi:scale-unbalanced
- platform: template
internal: false
name: "${friendly_name} Auto Tare"
lambda: |-
return id(auto_tare_difference);
unit_of_measurement: w
update_interval: 1s
state_class: measurement
disabled_by_default: true
icon: mdi:scale-balance
- platform: template
internal: true
name: "${friendly_name} Initial Zero"
lambda: |-
return id(initial_zero);
unit_of_measurement: w
state_class: measurement
update_interval: 60s
disabled_by_default: true
# RAW Scale input
- platform: hx711
id: hx711_value_raw
internal: true
dout_pin: ${dout_pin}
clk_pin: ${clk_pin}
gain: 128
accuracy_decimals: 3
update_interval: 0.2s
filters:
- lambda: !lambda |-
if (x > 8388000.0) return {};
if (x < -8388000.0) return {};
return x;
- sliding_window_moving_average:
window_size: 3
send_every: 1
on_value:
then:
- sensor.template.publish:
id: hx711_value
state: !lambda 'return id(hx711_value_raw).state;'
- if:
condition:
and:
- lambda: 'return id(auto_tare_enabled);'
# current smart scale value is below approx. 10KG (raw value -375000 aka nobody is standing on the scale
- lambda: 'return id(hx711_value).state < 10.0;'
then:
- if:
condition:
# current raw scale value is below expected zero value
- lambda: 'return id(hx711_value_raw).state < (id(initial_zero) - id(auto_tare_difference));'
then:
# INcrease Auto-Tare offset to slowly align real zero value with expected zero value
- lambda: |-
id(auto_tare_difference) += 10;
else:
# DEcrease Auto-Tare offset to slowly align real zero value with expected zero value
- lambda: |-
id(auto_tare_difference) -= 10;
# Mapped value to lbs
- platform: template
id: hx711_value
name: "${friendly_name} Weight"
internal: False
icon: mdi:weight-pound
unit_of_measurement: lbs
accuracy_decimals: 0
update_interval: 0.5s
state_class: measurement
filters:
# apply auto_tare difference
- lambda: 'return x + id(auto_tare_difference);'
# apply rough calibration
- calibrate_linear:
# retrieve these values by evaluating the raw values with loads of known mass.
# note that a bigger difference between measurements usually results in higher resolution,
# so measure 0 Kg and the highest known mass you have (like f.ex. your own weight, measured by a normal scale with good accuracy)
# 1221300 difference between the two
# was at -23800 for the longest time
- ${loadcell_zero} -> 0
- ${loadcell_load} -> ${loadcell_weight}
# map values below 0.1 to 0 (to decrease value changes due to random fluctuation)
- lambda: |-
if (x <= 0.1 || id(hx711_error).state) {
return 0.0;
} else {
return x;
}
binary_sensor:
- platform: template
device_class: occupancy
name: "${friendly_name} Occupied"
icon: mdi:bed
lambda: |-
if (
id(hx711_value).state >= id(occupied).state || id(occupancy_forced)
) {
return true;
} else {
return false;
}
- platform: template
name: "${friendly_name} HX711 Error"
id: hx711_error
device_class: problem
lambda: |-
if (
id(hx711_value_raw).raw_state > 8388000.0 || id(hx711_value_raw).raw_state < -8388000.0
) {
return true;
} else {
return false;
}
switch:
- platform: template
id: force_occupancy
name: "${friendly_name} Force Occupancy"
lambda: |-
return id(occupancy_forced);
turn_on_action:
- lambda: |-
id(occupancy_forced) = true;
turn_off_action:
- lambda: |-
id(occupancy_forced) = false;
- platform: template
id: auto_tare
# optimistic: true
# assumed_state: true
name: "${friendly_name} Auto Tare"
lambda: |-
return id(auto_tare_enabled);
turn_on_action:
- lambda: |-
id(auto_tare_enabled) = true;
turn_off_action:
- lambda: |-
id(auto_tare_enabled) = false;
button:
- platform: template
id: manual_tare
name: "${friendly_name} Manual Tare"
on_press:
- lambda: |-
id(auto_tare_difference) = id(initial_zero) - id(hx711_value_raw).state;
- platform: template
id: reset_tare
name: "${friendly_name} Reset Tare"
on_press:
- lambda: |-
id(auto_tare_difference) = 0;
+192
View File
@@ -0,0 +1,192 @@
globals:
- id: initial_zero
type: float
restore_value: yes
# NOTE: make sure to align this value to the one used in "calibrate_linear" below!
initial_value: ${loadcell_zero}
- id: auto_tare_enabled
type: bool
restore_value: yes
initial_value: 'true'
- id: auto_tare_difference
type: float
restore_value: yes
initial_value: '0'
- id: occupancy_forced
type: bool
restore_value: no
initial_value: 'false'
sensor:
- platform: homeassistant
entity_id: input_number.${entity_name}_occupied
internal: true
id: occupied
- platform: template
name: "${friendly_name} Raw Value"
lambda: |-
return id(hx711_value_raw).raw_state;
unit_of_measurement: w
update_interval: 1s
state_class: measurement
- platform: template
name: "${friendly_name} Auto Tare"
lambda: |-
return id(auto_tare_difference);
unit_of_measurement: w
update_interval: 1s
state_class: measurement
- platform: template
name: "${friendly_name} Initial Zero"
lambda: |-
return id(initial_zero);
unit_of_measurement: w
state_class: measurement
update_interval: 60s
# RAW Scale input
- platform: hx711
id: hx711_value_raw
internal: True
dout_pin: ${dout_pin}
clk_pin: ${clk_pin}
gain: 128
accuracy_decimals: 3
update_interval: 0.2s
filters:
- lambda: !lambda |-
if (x > 8388000.0) return {};
if (x < -8388000.0) return {};
return x;
- sliding_window_moving_average:
window_size: 15
send_every: 15
on_value:
then:
- sensor.template.publish:
id: hx711_value
state: !lambda 'return id(hx711_value_raw).state;'
- if:
condition:
and:
- lambda: 'return id(auto_tare_enabled);'
# current smart scale value is below approx. 10KG (raw value -375000 aka nobody is standing on the scale
- lambda: 'return id(hx711_value).state < 10.0;'
then:
- if:
condition:
# current raw scale value is below expected zero value
- lambda: 'return id(hx711_value_raw).state < (id(initial_zero) - id(auto_tare_difference));'
then:
# INcrease Auto-Tare offset to slowly align real zero value with expected zero value
- lambda: |-
id(auto_tare_difference) += 10;
else:
# DEcrease Auto-Tare offset to slowly align real zero value with expected zero value
- lambda: |-
id(auto_tare_difference) -= 10;
# Mapped value to lbs
- platform: template
id: hx711_value
name: "${friendly_name} Weight"
internal: False
filters:
# apply auto_tare difference
- lambda: 'return x + id(auto_tare_difference);'
# apply rough calibration
- calibrate_linear:
# retrieve these values by evaluating the raw values with loads of known mass.
# note that a bigger difference between measurements usually results in higher resolution,
# so measure 0 Kg and the highest known mass you have (like f.ex. your own weight, measured by a normal scale with good accuracy)
# 1221300 difference between the two
# was at -23800 for the longest time
- ${loadcell_zero} -> 0
- ${loadcell_load} -> ${loadcell_weight}
# map values below 0.1 to 0 (to decrease value changes due to random fluctuation)
- lambda: |-
if (x <= 0.1 || id(hx711_error).state) {
return 0.0;
} else {
return x;
}
unit_of_measurement: lbs
accuracy_decimals: 0
update_interval: 0.5s
state_class: measurement
binary_sensor:
- platform: template
device_class: occupancy
name: "${friendly_name} Occupied"
icon: mdi:bed
lambda: |-
if (
id(hx711_value).state >= id(occupied).state || id(occupancy_forced)
) {
return true;
} else {
return false;
}
- platform: template
name: "${friendly_name} HX711 Error"
id: hx711_error
device_class: problem
lambda: |-
if (
id(hx711_value_raw).raw_state > 8388000.0 || id(hx711_value_raw).raw_state < -8388000.0
) {
return true;
} else {
return false;
}
switch:
- platform: template
id: force_occupancy
name: "${friendly_name} Force Occupancy"
lambda: |-
return id(occupancy_forced);
turn_on_action:
- lambda: |-
id(occupancy_forced) = true;
turn_off_action:
- lambda: |-
id(occupancy_forced) = false;
- platform: template
id: auto_tare
# optimistic: true
# assumed_state: true
name: "${friendly_name} Auto Tare"
lambda: |-
return id(auto_tare_enabled);
turn_on_action:
- lambda: |-
id(auto_tare_enabled) = true;
turn_off_action:
- lambda: |-
id(auto_tare_enabled) = false;
button:
- platform: template
id: manual_tare
name: "${friendly_name} Manual Tare"
on_press:
- lambda: |-
id(auto_tare_difference) = id(initial_zero) - id(hx711_value_raw).state;
- platform: template
id: reset_tare
name: "${friendly_name} Reset Tare"
on_press:
- lambda: |-
id(auto_tare_difference) = 0;
+16
View File
@@ -0,0 +1,16 @@
ethernet:
id: eth
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO0_IN
phy_addr: 0
manual_ip:
static_ip: ${static_ip}
gateway: !secret iot_default_gateway
subnet: !secret iot_subnet_mask
#text_sensor:
#- <<: !include text_sensor/ethernet_ip_address.config.yaml
#- <<: !include text_sensor/ethernet_mac_address.config.yaml
+18
View File
@@ -0,0 +1,18 @@
ethernet:
id: eth
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
power_pin: GPIO12
manual_ip:
static_ip: ${static_ip}
gateway: !secret iot_default_gateway
subnet: !secret iot_subnet_mask
dns1: !secret iot_default_dns1
#text_sensor:
#- <<: !include text_sensor/ethernet_ip_address.config.yaml
#- <<: !include text_sensor/ethernet_mac_address.config.yaml
+9
View File
@@ -0,0 +1,9 @@
filters:
- median:
window_size: 5
send_every: 2
send_first_at: 1
- or:
- throttle: 5min
- delta: 1.0
- delta: .1
@@ -0,0 +1,4 @@
platform: wifi_signal
name: ${friendly_name} RSSI
id: ${entity_name}_rssi
update_interval: 60s
@@ -0,0 +1,4 @@
platform: uptime
name: ${friendly_name} Uptime
id: ${entity_name}_uptime
disabled_by_default: true
@@ -0,0 +1,10 @@
# Text sensors with general information.
platform: template
#ip_address:
name: ${friendly_name} IP
id: ${entity_name}_ip
icon: mdi:ip-network
entity_category: diagnostic
disabled_by_default: true
lambda: return {id(eth).get_ip_address().str() };
update_interval: 60s
@@ -0,0 +1,10 @@
# Text sensors with general information.
platform: template
#mac_address:
name: ${friendly_name} Ethernet MAC Address
id: ${entity_name}_ethernet_mac_address
disabled_by_default: true
icon: mdi:network
entity_category: diagnostic
lambda: return {esp_eth_get_mac.str() };
update_interval: 60s
@@ -0,0 +1,5 @@
# platform: version
# name: ${friendly_name} ESPHome Version
# id: ${entity_name}_version
# hide_timestamp: true
# disabled_by_default: true
@@ -0,0 +1,22 @@
# Text sensors with general information.
platform: wifi_info
ip_address:
name: ${friendly_name} IP
id: ${entity_name}_ip
icon: mdi:ip
disabled_by_default: true
ssid:
name: ${friendly_name} SSID
id: ${entity_name}_ssid
icon: mdi:lan
disabled_by_default: true
bssid:
name: ${friendly_name} BSSID
id: ${entity_name}_bssid
disabled_by_default: true
icon: mdi:router-network
mac_address:
name: ${friendly_name} Wifi MAC Address
id: ${entity_name}_wifi_mac_address
disabled_by_default: true
icon: mdi:wifi-cog
@@ -0,0 +1,13 @@
esp32_touch:
setup_mode: ${setup_mode}
binary_sensor:
- platform: esp32_touch
name: "${friendly_name} Occupied"
pin: ${touch_pin}
device_class: occupancy
icon: mdi:bed
threshold: ${threshold}
filters:
- delayed_on: 5s
- delayed_off: 10s
+28
View File
@@ -0,0 +1,28 @@
captive_portal:
wifi:
power_save_mode: none
networks:
- ssid: !secret Wifi_SSID
password: !secret Wifi_PWD
#- ssid: !secret IoT_Wifi_SSID
# password: !secret IoT_Wifi_PWD
manual_ip:
static_ip: ${static_ip}
gateway: !secret iot_default_gateway
subnet: !secret iot_subnet_mask
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
password: !secret EspHome_AP_PWD
# Enable fast connect
fast_connect: true
sensor:
- <<: !include sensor/rssi_sensor.config.yaml
text_sensor:
- <<: !include text_sensor/wifi_sensor.config.yaml
+20
View File
@@ -0,0 +1,20 @@
captive_portal:
wifi:
power_save_mode: none
networks:
- ssid: !secret Wifi_SSID
password: !secret Wifi_PWD
- ssid: !secret IoT_Wifi_SSID
password: !secret IoT_Wifi_PWD
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
password: !secret EspHome_AP_PWD
sensor:
- <<: !include sensor/rssi_sensor.config.yaml
text_sensor:
- <<: !include text_sensor/wifi_sensor.config.yaml
+27
View File
@@ -0,0 +1,27 @@
captive_portal:
wifi:
networks:
- ssid: !secret Wifi_SSID
password: !secret Wifi_PWD
#- ssid: !secret IoT_Wifi_SSID
# password: !secret IoT_Wifi_PWD
manual_ip:
static_ip: ${static_ip}
gateway: !secret iot_default_gateway
subnet: !secret iot_subnet_mask
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
password: !secret EspHome_AP_PWD
# Enable fast connect
fast_connect: true
sensor:
- <<: !include sensor/rssi_sensor.config.yaml
text_sensor:
- <<: !include text_sensor/wifi_sensor.config.yaml
+121
View File
@@ -0,0 +1,121 @@
substitutions:
devicename: front-yard-plant-monitor
entity_name: front_yard_plant_monitor
friendly_name: Front Yard Plant Monitor
platform: ESP32
board: esp32-poe-iso #nodemcu-32s
static_ip: !secret front-yard-plant-monitor-ip
packages:
#wifi: !include common/wifi_no_power_save.yaml
ethernet: !include common/olimex-poe.yaml
device_base: !include common/device_base.yaml
ble_proxy: !include common/ble_proxy.yaml
logger:
level: DEBUG
logs:
ultrasonic.sensor: WARN
#hx711: INFO
#esp32_ble_tracker:
# xiaomi_ble:
# id: eth
# type: LAN8720
# mdc_pin: GPIO23
# mdio_pin: GPIO18
# clk_mode: GPIO17_OUT
# phy_addr: 0
# power_pin: GPIO5
#C4:7C:8D:6D:3E:AE
sensor:
# - platform: xiaomi_hhccjcy01
# mac_address: 'C4:7C:8D:6D:CE:A4'
# temperature:
# name: 'Plant Sensor 1: Temperature'
# moisture:
# name: 'Plant Sensor 1: Moisture'
# illuminance:
# name: 'Plant Sensor 1: Illuminance'
# conductivity:
# name: 'Plant Sensor 1: Soil Conductivity'
# battery_level:
# name: 'Plant Sensor 1: Battery Level'
# - platform: xiaomi_hhccjcy01
# mac_address: 'C4:7C:8D:6D:3E:AE'
# temperature:
# name: 'Plant Sensor 2: Temperature'
# moisture:
# name: 'Plant Sensor 2: Moisture'
# illuminance:
# name: 'Plant Sensor 2: Illuminance'
# conductivity:
# name: 'Plant Sensor 2: Soil Conductivity'
# battery_level:
# name: 'Plant Sensor 2: Battery Level'
# - platform: xiaomi_hhccjcy01
# mac_address: 'C4:7C:8D:6D:3E:B0'
# temperature:
# name: 'Plant Sensor 3: Temperature'
# moisture:
# name: 'Plant Sensor 3: Moisture'
# illuminance:
# name: 'Plant Sensor 3: Illuminance'
# conductivity:
# name: 'Plant Sensor 3: Soil Conductivity'
# battery_level:
# name: 'Plant Sensor 3: Battery Level'
- platform: ultrasonic
trigger_pin: GPIO13
echo_pin: GPIO14
name: "Car Sensor East Side"
timeout: 4.0m
update_interval: 0.5s
filters:
- or:
- throttle_average: 30s
- delta: 0.5
- sliding_window_moving_average:
window_size: 5
send_every: 5
- delta: 0.0254
- platform: ultrasonic
trigger_pin: GPIO15
echo_pin: GPIO16
name: "Car Sensor West Side"
timeout: 4.0m
update_interval: 0.5s
filters:
- or:
- throttle_average: 30s
- delta: 0.5
- sliding_window_moving_average:
window_size: 5
send_every: 5
- delta: 0.0254
binary_sensor:
- platform: gpio
name: Outer Garage Door
device_class: door
pin:
mode: INPUT_PULLUP
number: GPIO5
- platform: gpio
name: Inner Garage Door
device_class: door
pin:
mode: INPUT_PULLUP
number: GPIO4
+221
View File
@@ -0,0 +1,221 @@
substitutions:
devicename: furnace-room-multisensor
entity_name: furnace_room_multisensor
friendly_name: Furnace Room MultiSensor
platform: ESP32
board: nodemcu-32s
static_ip: !secret furnace-room-multisensor-ip
packages:
#wifi: !include common/wifi.yaml
ethernet: !include common/olimex-poe.yaml
device_base: !include common/device_base.yaml
ble_proxy: !include common/ble_proxy.yaml
logger:
level: DEBUG
logs:
dallas.sensor: NONE
sensor: NONE
globals:
- id: screen_power
type: bool
restore_value: yes
initial_value: 'true'
font:
- file: 'CascadiaMonoPL.ttf'
id: font1
size: 17
dallas:
- pin:
number: GPIO5 #D4
update_interval: 10s
i2c:
sda: GPIO13 #D1
scl: GPIO15 #D2
frequency: 800kHz
display:
- platform: ssd1306_i2c
id: oled
model: "SSD1306 128x64"
#reset_pin: GPIO14 #D0
address: 0x3C
lambda: |-
it.print(0, 0, id(font1), "Delt:");
it.printf(128, 0, id(font1), TextAlign::TOP_RIGHT, "%.1f°F", id(hvac_delta).state);
it.print(0, 16, id(font1), "HVAC:");
it.printf(128, 16, id(font1), TextAlign::TOP_RIGHT, "%.1f°F", id(hvac).state);
it.print(0, 32, id(font1), "Retn:");
it.printf(128, 32, id(font1), TextAlign::TOP_RIGHT, "%.1f°F", id(hvac_return).state);
it.print(0, 48, id(font1), "Ambt:");
it.printf(128, 48, id(font1), TextAlign::TOP_RIGHT, "%.1f°F", id(ambient).state);
sensor:
- platform: dallas
address: 0xB33C01B607798528
name: "Return Temperature"
id: hvac_return
filters:
- lambda: return x * (9.0/5.0) + 32.0;
unit_of_measurement: "°F"
state_class: measurement
- platform: dallas
address: 0x0F3C01B6070C1328
name: "HVAC Temperature"
id: hvac
filters:
- lambda: return x * (9.0/5.0) + 32.0;
unit_of_measurement: "°F"
state_class: measurement
- platform: dallas
address: 0xFA3C01B607005B28
name: "Furnace Room Temperature"
id: ambient
filters:
- lambda: return x * (9.0/5.0) + 32.0;
unit_of_measurement: "°F"
state_class: measurement
- platform: template
name: "HVAC Delta"
id: hvac_delta
lambda: |-
return (id(hvac).state - id(hvac_return).state);
update_interval: 10s
unit_of_measurement: "°F"
state_class: measurement
filters:
- or:
- throttle: 60s
- delta: 1.0
# - platform: ultrasonic
# trigger_pin: GPIO1 #D7
# echo_pin: GPIO5 #D8
# name: "Salt Level in percent"
# update_interval: 1s
# #update_interval: 10s
# filters:
# - lambda: return (0.86-x)*(100/0.86);
# unit_of_measurement: "%"
# - platform: ultrasonic
# trigger_pin: GPIO33 #D7
# echo_pin: GPIO35 #D8
# unit_of_measurement: "cm"
# id: distance_from_bottom
# name: "Salt Level in CM"
# # pulse_time: 10us
# #update_interval: 3h
# #update_interval: 5s
# #timeout: 4.0m
# update_interval: 5s
# filters:
# - lambda: return ( 0.86 - x * 100;
# - sliding_window_moving_average:
# window_size: 5
# send_every: 5
# send_first_at: 1
- platform: ultrasonic
trigger_pin: GPIO33 #D7
echo_pin: GPIO35 #D8
id: ultrasonic_source
#update_interval: 5s
internal: True
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 5
send_first_at: 1
on_value:
then:
- sensor.template.publish:
id: distance_from_bottom
state: !lambda 'return id(ultrasonic_source).state;'
- sensor.template.publish:
id: distance_from_top
state: !lambda 'return id(ultrasonic_source).state;'
- platform: template
unit_of_measurement: "cm"
state_class: measurement
id: distance_from_bottom
name: "Salt Level in CM"
#update_interval: 5s
filters:
- lambda: 'return (0.94 - (id(ultrasonic_source).state)) * 100;'
on_value:
then:
- sensor.template.publish:
id: level_in_bags
state: !lambda 'return id(distance_from_bottom).state;'
- platform: template
unit_of_measurement: "cm"
state_class: measurement
id: distance_from_top
name: "Salt Level From Top in CM"
#update_interval: 5s
filters:
- lambda: 'return (id(ultrasonic_source).state) * 100;'
- platform: template
unit_of_measurement: "bags"
state_class: measurement
id: level_in_bags
name: "Salt Level in Bags"
#update_interval: 5s
filters:
- lambda: 'return (id(distance_from_bottom).state) / 17.5;'
binary_sensor:
- platform: gpio
name: "Furnace Room Door"
device_class: door
pin:
number: GPIO3 #D5
mode: INPUT_PULLUP
- platform: homeassistant
internal: true
id: light_state
entity_id: light.furnace_room
on_state:
then:
- if:
condition:
lambda: 'return id(light_state).state;'
then:
- logger.log: "The light is on"
else:
- logger.log: "The is off. Turning off display"
- switch.turn_off: display_switch
switch:
- platform: template
id: display_switch
name: "HVAC Display Switch"
lambda: |-
if (id(screen_power)) {
id(oled).turn_on();
} else {
id(oled).turn_off();
}
return id(screen_power);
turn_on_action:
- lambda: |-
id(screen_power) = true;
// id(oled).turn_on();
turn_off_action:
- lambda: |-
id(screen_power) = false;
// id(oled).turn_off();
+106
View File
@@ -0,0 +1,106 @@
substitutions:
devicename: kitchen-appliance-temps
entity_name: kitchen_appliance_temps
friendly_name: Kitchen Appliance Temps
platform: ESP32
board: esp32dev
static_ip: !secret kitchen-appliance-temps-ip
# Enable logging
logger:
level: DEBUG
packages:
wifi: !include common/wifi.yaml
device_base: !include common/device_base.yaml
i2c:
sda: GPIO21
scl: GPIO22
scan: true
id: i2c_bus_a
spi:
clk_pin: GPIO18
miso_pin: GPIO19
mosi_pin: GPIO23
id: spi_bus_a
mcp23017:
- id: 'mcp23017_hub_a'
address: 0x20
sensor:
- platform: max31855
#- platform: max6675
name: "Oven Temperature"
cs_pin: GPIO25
#update_interval: 5s
update_interval: 1s
unit_of_measurement: "°C"
device_class: temperature
state_class: measurement
accuracy_decimals: 0
filters:
- or:
- heartbeat: 60s
- delta: 18.0
- lambda: !lambda |-
if (x > 320) return {};
if (x < -10) return {};
return x;
- platform: max31855
name: "Fridge Temperature"
cs_pin: GPIO32
update_interval: 5s
unit_of_measurement: "°C"
device_class: temperature
state_class: measurement
accuracy_decimals: 0
filters:
- or:
- heartbeat: 60s
- delta: 1.8
- lambda: !lambda |-
if (x > 320) return {};
if (x < -10) return {};
return x;
- platform: max31855
name: "Freezer Temperature"
cs_pin: GPIO33
update_interval: 5s
unit_of_measurement: "°C"
device_class: temperature
state_class: measurement
accuracy_decimals: 0
filters:
- or:
- heartbeat: 60s
- delta: 1.8
- lambda: !lambda |-
if (x > 320) return {};
if (x < -10) return {};
return x;
binary_sensor:
- platform: gpio
name: "Fridge Door"
pin:
mcp23xxx: mcp23017_hub_a
number: 0
mode:
input: true
pullup: true
inverted: false
- platform: gpio
name: "Freezer Door"
pin:
mcp23xxx: mcp23017_hub_a
number: 1
mode:
input: true
pullup: true
inverted: false
+25
View File
@@ -0,0 +1,25 @@
substitutions:
devicename: master-bed
entity_name: master_bed
friendly_name: Master Bed
platform: ESP32
board: wemos_d1_mini32
static_ip: !secret master-bed-ip
dout_pin: !secret master-bed-dout
clk_pin: !secret master-bed-clk
loadcell_zero: !secret master-bed-zero
loadcell_load: !secret master-bed-load
loadcell_weight: !secret master-bed-weight
# Enable logging
logger:
level: DEBUG
logs:
sensor: INFO
hx711: DEBUG
packages:
wifi: !include common/ethernet.yaml
device_base: !include common/device_base.yaml
hx711: !include common/hx711_single_verbose.yaml
ble_proxy: !include common/ble_proxy.yaml
+369
View File
@@ -0,0 +1,369 @@
substitutions:
devicename: nursery-tagreader
entity_name: nursery_tagreader
friendly_name: Nursery Tagreader
platform: ESP8266
board: d1_mini
static_ip: !secret nursery-tagreader-ip
packages:
wifi: !include common/wifi.yaml
device_base: !include common/device_base.yaml
esphome:
# If buzzer is enabled, notify on api connection success
on_boot:
priority: -10
then:
- wait_until:
api.connected:
- logger.log: API is connected!
- rtttl.play: "success:d=24,o=5,b=100:c,g,b"
- light.turn_on:
id: activity_led
brightness: 100%
red: 0%
green: 0%
blue: 100%
flash_length: 500ms
- switch.turn_on: buzzer_enabled
- switch.turn_on: led_enabled
# Define switches to control LED and buzzer from HA
switch:
- platform: template
name: "${friendly_name} Buzzer Enabled"
id: buzzer_enabled
icon: mdi:volume-high
optimistic: true
restore_mode: restore_default_on
entity_category: config
- platform: template
name: "${friendly_name} LED enabled"
id: led_enabled
icon: mdi:alarm-light-outline
optimistic: true
restore_mode: restore_default_on
entity_category: config
# Define buttons for writing tags via HA
button:
- platform: template
name: Write Tag Random
id: write_tag_random
# Optional variables:
icon: "mdi:pencil-box"
on_press:
then:
- light.turn_on:
id: activity_led
brightness: 100%
red: 100%
green: 0%
blue: 100%
- lambda: |-
static const char alphanum[] = "0123456789abcdef";
std::string uri = "https://www.home-assistant.io/tag/";
for (int i = 0; i < 8; i++)
uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
uri += "-";
for (int j = 0; j < 3; j++) {
for (int i = 0; i < 4; i++)
uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
uri += "-";
}
for (int i = 0; i < 12; i++)
uri += alphanum[random_uint32() % (sizeof(alphanum) - 1)];
auto message = new nfc::NdefMessage();
message->add_uri_record(uri);
ESP_LOGD("tagreader", "Writing payload: %s", uri.c_str());
id(pn532_board).write_mode(message);
- rtttl.play: "write:d=24,o=5,b=100:b"
- wait_until:
not:
pn532.is_writing:
- light.turn_off:
id: activity_led
- rtttl.play: "write:d=24,o=5,b=100:b,b"
- platform: template
name: Clean Tag
id: clean_tag
icon: "mdi:nfc-variant-off"
on_press:
then:
- light.turn_on:
id: activity_led
brightness: 100%
red: 100%
green: 64.7%
blue: 0%
- lambda: 'id(pn532_board).clean_mode();'
- rtttl.play: "write:d=24,o=5,b=100:b"
- wait_until:
not:
pn532.is_writing:
- light.turn_off:
id: activity_led
- rtttl.play: "write:d=24,o=5,b=100:b,b"
- platform: template
name: Cancel writing
id: cancel_writing
icon: "mdi:pencil-off"
on_press:
then:
- lambda: 'id(pn532_board).read_mode();'
- light.turn_off:
id: activity_led
- rtttl.play: "write:d=24,o=5,b=100:b,b"
# Enable logging
logger:
# level: VERY_VERBOSE
level: INFO
# Enable Home Assistant API
api:
services:
- service: rfidreader_tag_ok
then:
- rtttl.play: "beep:d=16,o=5,b=100:b"
- service: rfidreader_tag_ko
then:
- rtttl.play: "beep:d=8,o=5,b=100:b"
- service: play_rtttl
variables:
song_str: string
then:
- rtttl.play: !lambda 'return song_str;'
- service: write_tag_id
variables:
tag_id: string
then:
- light.turn_on:
id: activity_led
brightness: 100%
red: 100%
green: 0%
blue: 0%
- lambda: |-
auto message = new nfc::NdefMessage();
std::string uri = "https://www.home-assistant.io/tag/";
uri += tag_id;
message->add_uri_record(uri);
id(pn532_board).write_mode(message);
- rtttl.play: "write:d=24,o=5,b=100:b"
- wait_until:
not:
pn532.is_writing:
- light.turn_off:
id: activity_led
- rtttl.play: "write:d=24,o=5,b=100:b,b"
- service: write_music_tag
variables:
music_url: string
music_info: string
then:
- light.turn_on:
id: activity_led
brightness: 100%
red: 100%
green: 0%
blue: 0%
- lambda: |-
auto message = new nfc::NdefMessage();
std::string uri = "";
std::string text = "";
uri += music_url;
text += music_info;
if ( music_url != "" ) {
message->add_uri_record(uri);
}
if ( music_info != "" ) {
message->add_text_record(text);
}
id(pn532_board).write_mode(message);
- rtttl.play: "write:d=24,o=5,b=100:b"
- wait_until:
not:
pn532.is_writing:
- light.turn_off:
id: activity_led
- rtttl.play: "write:d=24,o=5,b=100:b,b"
# Enable OTA upgrade
ota:
i2c:
scan: False
frequency: 400kHz
globals:
- id: source
type: std::string
- id: url
type: std::string
- id: info
type: std::string
pn532_i2c:
id: pn532_board
on_tag:
then:
- if:
condition:
switch.is_on: led_enabled
then:
- light.turn_on:
id: activity_led
brightness: 100%
red: 0%
green: 100%
blue: 0%
flash_length: 500ms
- delay: 0.15s #to fix slow component
- lambda: |-
id(source)="";
id(url)="";
id(info)="";
if (tag.has_ndef_message()) {
auto message = tag.get_ndef_message();
auto records = message->get_records();
for (auto &record : records) {
std::string payload = record->get_payload();
std::string type = record->get_type();
size_t hass = payload.find("https://www.home-assistant.io/tag/");
size_t applemusic = payload.find("https://music.apple.com");
size_t spotify = payload.find("https://open.spotify.com");
size_t sonos = payload.find("sonos-2://");
if (type == "U" and hass != std::string::npos ) {
ESP_LOGD("tagreader", "Found Home Assistant tag NDEF");
id(source)="hass";
id(url)=payload;
id(info)=payload.substr(hass + 34);
}
else if (type == "U" and applemusic != std::string::npos ) {
ESP_LOGD("tagreader", "Found Apple Music tag NDEF");
id(source)="amusic";
id(url)=payload;
}
else if (type == "U" and spotify != std::string::npos ) {
ESP_LOGD("tagreader", "Found Spotify tag NDEF");
id(source)="spotify";
id(url)=payload;
}
else if (type == "U" and sonos != std::string::npos ) {
ESP_LOGD("tagreader", "Found Sonos app tag NDEF");
id(source)="sonos";
id(url)=payload;
}
else if (type == "T" ) {
ESP_LOGD("tagreader", "Found music info tag NDEF");
id(info)=payload;
}
else if ( id(source)=="" ) {
id(source)="uid";
}
}
}
else {
id(source)="uid";
}
- if:
condition:
lambda: 'return ( id(source)=="uid" );'
then:
- homeassistant.tag_scanned: !lambda |-
ESP_LOGD("tagreader", "No HA NDEF, using UID");
return x;
else:
- if:
condition:
lambda: 'return ( id(source)=="hass" );'
then:
- homeassistant.tag_scanned: !lambda 'return id(info);'
else:
- homeassistant.event:
event: esphome.music_tag
data:
reader: !lambda |-
return App.get_name().c_str();
source: !lambda |-
return id(source);
url: !lambda |-
return id(url);
info: !lambda |-
return id(info);
- if:
condition:
switch.is_on: buzzer_enabled
then:
- rtttl.play: "success:d=24,o=5,b=100:c,g,b"
# Define the buzzer output
output:
- platform: esp8266_pwm
pin: D7
id: buzzer
binary_sensor:
- platform: gpio
name: Nursery Door
device_class: door
pin:
mode: INPUT_PULLUP
number: D5
# # - platform: gpio
# # name: "Nursery Closet"
# # device_class: door
# # pin:
# # number: D6
# # mode: INPUT_PULLUP
# - platform: status
# name: "${friendly_name} Status"
# entity_category: diagnostic
# text_sensor:
# - platform: version
# hide_timestamp: true
# name: "${friendly_name} ESPHome Version"
# entity_category: diagnostic
# - platform: wifi_info
# ip_address:
# name: "${friendly_name} IP Address"
# icon: mdi:wifi
# entity_category: diagnostic
# ssid:
# name: "${friendly_name} Connected SSID"
# icon: mdi:wifi-strength-2
# entity_category: diagnostic
# Define buzzer as output for RTTTL
rtttl:
output: buzzer
# Configure LED
light:
- platform: neopixelbus
variant: WS2812
pin: D8
num_leds: 1
flash_transition_length: 500ms
type: GRB
id: activity_led
name: "${friendly_name} LED"
restore_mode: ALWAYS_OFF
+803
View File
@@ -0,0 +1,803 @@
# CT01 - A - Grid Phase A
# CT02 - G - Dryer
# CT03 - D - Furnace
# CT04 - B - Grid Phase B
# CT05 - E - Basement Plugs (Computer is on this circuit)
# CT06 - F - Nursery, Kitchen, and Dining Room Lights
# CT07 - C - Sump Pump Plug
# CT08 - H - Microwave Plug
# CT09 - I - Stove/Oven
# CT10 - J - Front Room Plugs
# CT11 - M - Heat Pump
# CT12 - L - Kitchen Circuit 1 (Fridge is on this circuit)
substitutions:
devicename: power-monitor
friendly_name: 'PM:'
entity_name: power_monitor
static_ip: !secret power-monitor-ip
platform: ESP32
board: nodemcu-32s
update_time: 500ms
kwh_report_interval: 60s
watt_heartbeat: 60s
throttle_time: 60s
watt_delta: "50.0"
#watt_delta: "5.0"
#grid_watt_delta: "10.0"
grid_watt_delta: "200.0"
#fast_update_time: 10s
#medium_update_time: 30s
#slow_update_time: 60s
ct01Name: 'Grid Phase A'
ct04Name: 'Grid Phase B'
ct22Name: 'Well' # 1, 3 # sct010 - O
ct12Name: 'Kitchen 1' # 5 # sct006 - L
ct16Name: 'Kitchen 2' # 7 # sct006 - S
ct18Name: 'Laundry Plug' # 9 # sct006 - N
ct08Name: 'Microwave Plug' # 11 # sct006 - H
ct17Name: 'Bathroom Plug' # 13 # sct006 - R
ct11Name: 'Heat Pump' # 15, 17 - M
ct24Name: 'Basement Bedroom and Furnace Room Lights' # 19 # sct006 - K
ct05Name: 'Basement Plugs' # 21a # sct006 - E
ct23Name: 'Basement and Laundry Lights and Plugs' # 21b # sct006 - W
ct07Name: 'Sump Pump Plug' # 23 # sct006 - C
ct06Name: 'Nursery, Dining, Kitchen Lights' # 2 # sct006 - F
ct20Name: 'Master Suite' # 4 # sct006 - T
ct03Name: 'Furnace' # 6 # sct006 - D
ct15Name: 'Basement Stairs and Lights' # 8 # sct006 - P
ct21Name: 'Dishwasher' # 10 # sct006 - V
ct13Name: 'Garage Outside and Front Garage Lights' # 12 # sct006 - U
ct10Name: 'Front Room Plugs' # 14 # sct006 - J
ct14Name: 'Garage and Outside Plugs' # 16 # sct006 - Q
ct09Name: 'Stove' # 18, 20 # sct016 - I
ct02Name: 'Dryer' # 22, 24 # sct010 - G
ct19Name: 'Unused'
# Current Transformers:
# 20A/25mA SCT-006: 11143
sct006: '11143'
# 30A/1V SCT-013-030: 8650
# 50A/1V SCT-013-050: 15420
# 80A/26.6mA SCT-010: 41660
sct010: '41660'
# 100A/50ma SCT-013-000: 27518
sct013: '27518'
# 120A/40mA: SCT-016: 41787
sct016: '41787'
# 200A/100mA SCT-024: 27518
#current_cal: '27518'
# Jameco 9VAC Transformer:
# For meter versions:
# >= v1.3: 7305
voltage_cal: '7305'
packages:
wifi: !include common/wifi.yaml
# device_base: !include common/complex_esp32_base.yaml
device_base: !include common/device_base.yaml
# web_server:
# port: 80
time:
- platform: sntp
id: sntp_time
logger:
level: DEBUG
logs:
sensor: DEBUG
spi:
clk_pin: 18
miso_pin: 19
mosi_pin: 23
sensor:
#IC1 Main
- platform: atm90e32
cs_pin: 5
phase_a:
voltage:
name: ${friendly_name} [V]
id: ic1Volts
filters:
- throttle_average: 60s
accuracy_decimals: 1
current:
name: ${friendly_name} ${ct01Name} [A]
id: ct1Amps
filters:
- or:
- delta: 2
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
power:
name: ${friendly_name} ${ct01Name} [W]
id: ct1Watts
filters:
- or:
- delta: ${grid_watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct016}
phase_b:
power:
name: ${friendly_name} ${ct02Name} [W]
id: ct2Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct010}
phase_c:
power:
name: ${friendly_name} ${ct03Name} [W]
id: ct3Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
frequency:
name: ${friendly_name} Freq A
filters:
- or:
- delta: 0.05
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
line_frequency: 60Hz
gain_pga: 1X
update_interval: ${update_time}
#IC2 Main
- platform: atm90e32
cs_pin: 4
phase_a:
current:
name: ${friendly_name} ${ct04Name} [A]
id: ct4Amps
filters:
- or:
- delta: ${grid_watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
power:
name: ${friendly_name} ${ct04Name} [W]
id: ct4Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
gain_voltage: ${voltage_cal}
gain_ct: ${sct016}
phase_b:
power:
name: ${friendly_name} ${ct05Name} [W]
id: ct5Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_c:
power:
name: ${friendly_name} ${ct06Name} [W]
id: ct6Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
frequency:
name: ${friendly_name} Freq B
filters:
- or:
- delta: 0.05
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
line_frequency: 60Hz
gain_pga: 1X
update_interval: ${update_time}
#IC1 AddOn 1
- platform: atm90e32
cs_pin: 0
phase_a:
power:
name: ${friendly_name} ${ct07Name} [W]
id: ct7Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_b:
power:
name: ${friendly_name} ${ct08Name} [W]
id: ct8Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
- multiply: -1
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_c:
power:
name: ${friendly_name} ${ct09Name} [W]
id: ct9Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct013}
line_frequency: 60Hz
gain_pga: 1X
update_interval: ${update_time}
#IC2 AddOn 1
- platform: atm90e32
cs_pin: 16
phase_a:
power:
name: ${friendly_name} ${ct10Name} [W]
id: ct10Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_b:
power:
name: ${friendly_name} ${ct11Name} [W]
id: ct11Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
- multiply: -1
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct010}
phase_c:
power:
name: ${friendly_name} ${ct12Name} [W]
id: ct12Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
- multiply: -1
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
line_frequency: 60Hz
gain_pga: 1X
update_interval: ${update_time}
#IC1 AddOn 2
- platform: atm90e32
cs_pin: 27
phase_a:
power:
name: ${friendly_name} ${ct13Name} [W]
id: ct13Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
- multiply: -1
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_b:
power:
name: ${friendly_name} ${ct14Name} [W]
id: ct14Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
- multiply: -1
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_c:
power:
name: ${friendly_name} ${ct15Name} [W]
id: ct15Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
- multiply: -1
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
line_frequency: 60Hz
gain_pga: 1X
update_interval: ${update_time}
#IC2 AddOn 2
- platform: atm90e32
cs_pin: 17
phase_a:
power:
name: ${friendly_name} ${ct16Name} [W]
id: ct16Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_b:
power:
name: ${friendly_name} ${ct17Name} [W]
id: ct17Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
- multiply: -1
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_c:
power:
name: ${friendly_name} ${ct18Name} [W]
id: ct18Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
- multiply: -1
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
line_frequency: 60Hz
gain_pga: 1X
update_interval: ${update_time}
#IC1 AddOn 3
- platform: atm90e32
#do not use GPIO2 if ESP32 has an on-board LED assigned to it
cs_pin: 2
phase_a:
power:
name: ${friendly_name} ${ct19Name} [W]
id: ct19Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_b:
power:
name: ${friendly_name} ${ct20Name} [W]
id: ct20Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_c:
power:
name: ${friendly_name} ${ct21Name} [W]
id: ct21Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
line_frequency: 60Hz
gain_pga: 1X
update_interval: ${update_time}
#IC2 AddOn 3
- platform: atm90e32
cs_pin: 21
phase_a:
power:
#name: ${friendly_name} ${ct22Name} [W]
internal: true
id: ct22Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct010}
phase_b:
power:
name: ${friendly_name} ${ct23Name} [W]
id: ct23Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
- multiply: -1
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
phase_c:
power:
name: ${friendly_name} ${ct24Name} [W]
id: ct24Watts
filters:
- or:
- delta: ${watt_delta}
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
- multiply: -1
accuracy_decimals: 1
gain_voltage: ${voltage_cal}
gain_ct: ${sct006}
line_frequency: 60Hz
gain_pga: 1X
update_interval: ${update_time}
#Total Amps From Grid
- platform: template
name: ${friendly_name} Grid Total [A]
id: totalAmpsFromGrid
lambda: return id(ct1Amps).state + id(ct4Amps).state ;
accuracy_decimals: 1
unit_of_measurement: A
device_class: current
state_class: measurement
update_interval: ${update_time}
filters:
- or:
- delta: 2.0
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
#Total Watts From Grid
- platform: template
name: ${friendly_name} Grid Total [W]
id: totalWattsFromGrid
lambda: return id(ct1Watts).state + id(ct4Watts).state ;
accuracy_decimals: 1
unit_of_measurement: W
device_class: power
state_class: measurement
update_interval: ${update_time}
filters:
- or:
- delta: 5.0
- throttle_average: ${throttle_time}
# - heartbeat: ${watt_heartbeat}
#kWh From Grid
- platform: total_daily_energy
name: ${friendly_name} Grid [kWh]
power_id: totalWattsFromGrid
filters:
- multiply: 0.001
# - heartbeat: ${kwh_report_interval}
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
# The CT for the Well needs to be calibrated.
# In the interim, I'm using this lambda
- platform: template
name: ${friendly_name} ${ct22Name} [W]
id: ct22WattsPositive
state_class: measurement
lambda: |-
if (id(ct22Watts).state < 0){
return 0;
} else {
return id(ct22Watts).state ;
}
accuracy_decimals: 1
unit_of_measurement: W
icon: mdi:lightning-bolt-circle
update_interval: ${update_time}
filters:
- delta: 5.0
# - heartbeat: ${watt_heartbeat}
# kWh from CT1
# This is included in the grid calculation
# kWh from CT2 (the dryer)
- platform: total_daily_energy
name: ${friendly_name} ${ct02Name} [kWh]
power_id: ct2Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 3
- platform: total_daily_energy
name: ${friendly_name} ${ct03Name} [kWh]
power_id: ct3Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
# kWh From CT 4
# This is included in the Grid calculation area
#kWh From CT 5
- platform: total_daily_energy
name: ${friendly_name} ${ct05Name} [kWh]
power_id: ct5Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 6
- platform: total_daily_energy
name: ${friendly_name} ${ct06Name} [kWh]
power_id: ct6Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 7
- platform: total_daily_energy
name: ${friendly_name} ${ct07Name} [kWh]
power_id: ct7Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 8
- platform: total_daily_energy
name: ${friendly_name} ${ct08Name} [kWh]
power_id: ct8Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 9
- platform: total_daily_energy
name: ${friendly_name} ${ct09Name} [kWh]
power_id: ct9Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 10
- platform: total_daily_energy
name: ${friendly_name} ${ct10Name} [kWh]
power_id: ct10Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 11 (Heat Pump)
- platform: total_daily_energy
name: ${friendly_name} ${ct11Name} [kWh]
power_id: ct11Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 12
- platform: total_daily_energy
name: ${friendly_name} ${ct12Name} [kWh]
power_id: ct12Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 13
- platform: total_daily_energy
name: ${friendly_name} ${ct13Name} [kWh]
power_id: ct13Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 14
- platform: total_daily_energy
name: ${friendly_name} ${ct14Name} [kWh]
power_id: ct14Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 15
- platform: total_daily_energy
name: ${friendly_name} ${ct15Name} [kWh]
power_id: ct15Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 16
- platform: total_daily_energy
name: ${friendly_name} ${ct16Name} [kWh]
power_id: ct16Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 17
- platform: total_daily_energy
name: ${friendly_name} ${ct17Name} [kWh]
power_id: ct17Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 18
- platform: total_daily_energy
name: ${friendly_name} ${ct18Name} [kWh]
power_id: ct18Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 19
# this is not used
# - platform: total_daily_energy
# name: ${friendly_name} ${ct19Name} [kWh]
# power_id: ct19Watts
# filters:
# - multiply: 0.001
# - throttle_average: ${kwh_report_interval}
# unit_of_measurement: kWh
# device_class: energy
# state_class: total_increasing
# # min_save_interval: ${update_time}
#kWh From CT 20
- platform: total_daily_energy
name: ${friendly_name} ${ct20Name} [kWh]
power_id: ct20Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 21
- platform: total_daily_energy
name: ${friendly_name} ${ct21Name} [kWh]
power_id: ct21Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 22
- platform: total_daily_energy
name: ${friendly_name} ${ct22Name} [kWh]
power_id: ct22WattsPositive
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 23
- platform: total_daily_energy
name: ${friendly_name} ${ct23Name} [kWh]
power_id: ct23Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
#kWh From CT 24
- platform: total_daily_energy
name: ${friendly_name} ${ct24Name} [kWh]
power_id: ct24Watts
filters:
- multiply: 0.001
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
# min_save_interval: ${update_time}
+24
View File
@@ -0,0 +1,24 @@
substitutions:
devicename: white-bed
entity_name: white_bed
friendly_name: White Bed
platform: ESP32
board: nodemcu-32s
static_ip: !secret white-bed-ip
dout_pin: !secret white-bed-dout
clk_pin: !secret white-bed-clk
loadcell_zero: !secret white-bed-zero
loadcell_load: !secret white-bed-load
loadcell_weight: !secret white-bed-weight
# Enable logging
logger:
level: DEBUG
logs:
sensor: INFO
hx711: DEBUG
packages:
wifi: !include common/wifi.yaml
device_base: !include common/device_base.yaml
hx711: !include common/hx711_single_verbose.yaml