substitutions: devicename: circuit-sensor entity_name: circuit_sensor friendly_name: Circuit Sensor board: esp32-s3-devkitc-1 framework: esp-idf comment: Clever ${friendly_name} name_prefix: 'PM:' static_ip: !secret circuit-sensor-ip update_time: 500ms kwh_report_interval: 60s watt_heartbeat: 60s throttle_time: 60s watt_delta: "50.0" grid_watt_delta: "200.0" # Current Transformer Names 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: sct006: '11143' sct010: '41660' sct013: '27518' sct016: '41787' voltage_cal: '7305' # Sensor Pins spi_clk: 7 spi_miso: 5 spi_mosi: 6 ic1_main: 8 ic1_addon1: 0 ic1_addon2: 7 ic1_addon3: 2 ic2_main: 4 ic2_addon1: 16 ic2_addon2: 17 ic2_addon3: 21 packages: network: !include common/waveshare_esp32_s3_eth.yaml device_base: !include common/device_base.yaml web_server: !include common/web_server.yaml esp32: board: ${board} framework: type: ${framework} time: - platform: sntp id: sntp_time timezone: America/Detroit # TODO: If I want to use this board, I'd need to translate PINs # https://www.waveshare.com/esp32-s3-eth.htm # Use a 40 pin ribbon cable so that the esp can be outside the breaker box? # https://github.com/CircuitSetup/Expandable-6-Channel-ESP32-Energy-Meter/blob/master/Software/ESPHome/README.md # QUESTION: Is there a way to separate the power so this can use POE # Either way, the power from the adapter would need to make it to the main board somehow. spi: clk_pin: ${spi_clk} miso_pin: ${spi_miso} mosi_pin: ${spi_mosi} interface: any sensor: #IC1 Main - platform: atm90e32 cs_pin: ${ic1_main} phase_a: voltage: name: ${name_prefix} [V] id: ic1Volts filters: - throttle_average: 60s accuracy_decimals: 1 current: name: ${name_prefix} ${ct01Name} [A] id: ct1Amps filters: - or: - delta: 2 - throttle_average: ${throttle_time} # - heartbeat: ${watt_heartbeat} power: name: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} 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: ${ic2_main} phase_a: current: name: ${name_prefix} ${ct04Name} [A] id: ct4Amps filters: - or: - delta: ${grid_watt_delta} - throttle_average: ${throttle_time} # - heartbeat: ${watt_heartbeat} accuracy_decimals: 1 power: name: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} 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: ${ic1_addon1} phase_a: power: name: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${ic2_addon1} phase_a: power: name: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${ic1_addon2} phase_a: power: name: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${ic2_addon2} phase_a: power: name: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${ic1_addon3} phase_a: power: name: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${ic2_addon3} phase_a: power: #name: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} 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: ${name_prefix} 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: ${name_prefix} 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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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: ${name_prefix} ${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}