mirror of
https://github.com/CeeWeasel/fresh-home.git
synced 2026-08-10 11:00:14 -04:00
initial push
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
platform: status
|
||||
name: "${friendly_name} Status"
|
||||
id: ${entity_name}_status
|
||||
@@ -0,0 +1,3 @@
|
||||
esp32_ble_beacon:
|
||||
type: iBeacon
|
||||
uuid: ${uuid}
|
||||
@@ -0,0 +1,8 @@
|
||||
esp32_ble_tracker:
|
||||
scan_parameters:
|
||||
interval: 1100ms
|
||||
window: 1100ms
|
||||
active: true
|
||||
|
||||
bluetooth_proxy:
|
||||
active: true
|
||||
@@ -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"
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user