pool light esp, gas heater esp, HA Overview display
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
##########################################################################################
|
||||
# GLOBAL VARIABLES
|
||||
# https://esphome.io/guides/automations.html?highlight=globals#global-variables
|
||||
##########################################################################################
|
||||
globals:
|
||||
####################################################
|
||||
# total_energy: cumulative power
|
||||
# Not restored, so each boot starts fresh at 0.
|
||||
####################################################
|
||||
- id: total_energy
|
||||
type: float
|
||||
restore_value: yes
|
||||
initial_value: '0.0'
|
||||
|
||||
##########################################################################################
|
||||
# UART
|
||||
# https://esphome.io/components/uart/
|
||||
##########################################################################################
|
||||
uart:
|
||||
# Needed for cse776. Set logging baud to 0 also.
|
||||
id: cse_uart
|
||||
rx_pin: RX # GPIO3 on ESP8266
|
||||
baud_rate: 4800
|
||||
parity: EVEN # CSE7766 requires EVEN
|
||||
|
||||
##########################################################################################
|
||||
# GENERAL COMMON SENSORS
|
||||
# https://esphome.io/components/sensor/
|
||||
##########################################################################################
|
||||
sensor:
|
||||
#############################################
|
||||
# CSE7766 POWER SENSOR
|
||||
# https://esphome.io/components/sensor/cse7766.html
|
||||
#############################################
|
||||
- platform: cse7766
|
||||
id: athom_cse7766
|
||||
uart_id: cse_uart
|
||||
current:
|
||||
name: "Current"
|
||||
id: plug_current # Added ID so we can reference this in other sensors
|
||||
icon: mdi:current-ac
|
||||
filters:
|
||||
- throttle_average: ${sensor_update_interval}
|
||||
- lambda: if (x < 0.060) return 0.0; else return x; # For the chip will report less than 3w power when no load is connected
|
||||
on_value_range:
|
||||
- above: ${current_limit}
|
||||
then:
|
||||
- switch.turn_off: relay
|
||||
|
||||
voltage:
|
||||
name: "Voltage"
|
||||
id: plug_voltage # Added ID so we can reference this in other sensors
|
||||
icon: mdi:sine-wave
|
||||
accuracy_decimals: 2
|
||||
filters:
|
||||
- throttle_average: ${sensor_update_interval}
|
||||
|
||||
power:
|
||||
name: "Power"
|
||||
id: power_sensor
|
||||
icon: mdi:power
|
||||
accuracy_decimals: 2
|
||||
filters:
|
||||
- throttle_average: ${sensor_update_interval}
|
||||
- lambda: if (x < 3.0) return 0.0; else return x; # For the chip will report less than 3w power when no load is connected
|
||||
|
||||
energy:
|
||||
name: "Energy"
|
||||
id: energy
|
||||
icon: mdi:lightning-bolt
|
||||
unit_of_measurement: kWh
|
||||
internal: ${hide_energy_sensor}
|
||||
filters:
|
||||
- throttle: ${sensor_update_interval}
|
||||
# Multiplication factor from W to kW is 0.001
|
||||
- multiply: 0.001
|
||||
accuracy_decimals: 2
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
static float previous_energy_value = 0.0;
|
||||
float current_energy_value = id(energy).state;
|
||||
id(total_energy) += current_energy_value - previous_energy_value;
|
||||
previous_energy_value = current_energy_value;
|
||||
id(total_energy_sensor).update();
|
||||
|
||||
apparent_power:
|
||||
name: "Apparent Power"
|
||||
icon: mdi:power
|
||||
accuracy_decimals: 2
|
||||
filters:
|
||||
- throttle_average: ${sensor_update_interval}
|
||||
|
||||
reactive_power:
|
||||
name: "Reactive Power"
|
||||
icon: mdi:flash
|
||||
accuracy_decimals: 2
|
||||
filters:
|
||||
- throttle_average: ${sensor_update_interval}
|
||||
|
||||
power_factor:
|
||||
name: "Power Factor"
|
||||
icon: mdi:percent-outline
|
||||
accuracy_decimals: 2
|
||||
filters:
|
||||
- throttle_average: ${sensor_update_interval}
|
||||
|
||||
#############################################
|
||||
# Total Energy (All Time)
|
||||
#############################################
|
||||
- platform: template
|
||||
name: "Total Energy"
|
||||
id: total_energy_sensor
|
||||
unit_of_measurement: kWh
|
||||
device_class: "energy"
|
||||
state_class: "total_increasing"
|
||||
icon: mdi:lightning-bolt
|
||||
accuracy_decimals: 3
|
||||
lambda: |-
|
||||
return id(total_energy);
|
||||
update_interval: "60s"
|
||||
|
||||
#############################################
|
||||
# Total Daily Energy
|
||||
# https://esphome.io/components/sensor/total_daily_energy.html
|
||||
#############################################
|
||||
- platform: total_daily_energy
|
||||
name: "Total Daily Energy"
|
||||
restore: true
|
||||
power_id: power_sensor
|
||||
unit_of_measurement: kWh
|
||||
icon: mdi:hours-24
|
||||
accuracy_decimals: 3
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
|
||||
##########################################################################################
|
||||
# STATUS LED
|
||||
# https://esphome.io/components/status_led.html
|
||||
##########################################################################################
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO13
|
||||
inverted: True
|
||||
|
||||
##########################################################################################
|
||||
# BINARY SENSORS
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
##########################################################################################
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: 5
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
id: power_button
|
||||
name: "Power Button"
|
||||
disabled_by_default: true
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at most 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- switch.toggle: relay
|
||||
#- timing:
|
||||
# - ON for at least 4s
|
||||
# then:
|
||||
# - button.press: Reset
|
||||
|
||||
##########################################################################################
|
||||
# SWITCH COMPONENT
|
||||
# https://esphome.io/components/switch/
|
||||
##########################################################################################
|
||||
switch:
|
||||
- platform: gpio
|
||||
name: "Switch"
|
||||
pin: GPIO12
|
||||
id: relay
|
||||
restore_mode: ${relay_restore_mode}
|
||||
icon: ${power_plug_type}
|
||||
Reference in New Issue
Block a user