mirror of
https://github.com/CeeWeasel/fresh-home.git
synced 2026-08-10 02:50:12 -04:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -6,33 +6,45 @@ sensor:
|
||||
############
|
||||
- platform: atm90e32
|
||||
release_device: true
|
||||
cs_pin: 0
|
||||
cs_pin: ${addon1_ic1}
|
||||
id: ${addon1_id1}
|
||||
phase_a:
|
||||
current:
|
||||
name: ${ct7_name} Amps
|
||||
name: ${ct7_name} ${amp_label}
|
||||
id: ct7Amps
|
||||
power:
|
||||
name: ${ct7_name} Watts
|
||||
name: ${ct7_name} ${watt_label}
|
||||
id: ct7Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal1}
|
||||
gain_ct: ${current_cal_ct7}
|
||||
phase_b:
|
||||
current:
|
||||
name: ${ct8_name} Amps
|
||||
name: ${ct8_name} ${amp_label}
|
||||
id: ct8Amps
|
||||
power:
|
||||
name: ${ct8_name} Watts
|
||||
name: ${ct8_name} ${watt_label}
|
||||
id: ct8Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal1}
|
||||
gain_ct: ${current_cal_ct8}
|
||||
phase_c:
|
||||
current:
|
||||
name: ${ct9_name} Amps
|
||||
name: ${ct9_name} ${amp_label}
|
||||
id: ct9Amps
|
||||
power:
|
||||
name: ${ct9_name} Watts
|
||||
name: ${ct9_name} ${watt_label}
|
||||
id: ct9Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal1}
|
||||
gain_ct: ${current_cal_ct9}
|
||||
line_frequency: ${electric_freq}
|
||||
@@ -44,33 +56,45 @@ sensor:
|
||||
############
|
||||
- platform: atm90e32
|
||||
release_device: true
|
||||
cs_pin: 16
|
||||
cs_pin: ${addon1_ic2}
|
||||
id: ${addon1_id2}
|
||||
phase_a:
|
||||
current:
|
||||
name: ${ct10_name} Amps
|
||||
name: ${ct10_name} ${amp_label}
|
||||
id: ct10Amps
|
||||
power:
|
||||
name: ${ct10_name} Watts
|
||||
name: ${ct10_name} ${watt_label}
|
||||
id: ct10Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal2}
|
||||
gain_ct: ${current_cal_ct10}
|
||||
phase_b:
|
||||
current:
|
||||
name: ${ct11_name} Amps
|
||||
name: ${ct11_name} ${amp_label}
|
||||
id: ct11Amps
|
||||
power:
|
||||
name: ${ct11_name} Watts
|
||||
name: ${ct11_name} ${watt_label}
|
||||
id: ct11Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal2}
|
||||
gain_ct: ${current_cal_ct11}
|
||||
phase_c:
|
||||
current:
|
||||
name: ${ct12_name} Amps
|
||||
name: ${ct12_name} ${amp_label}
|
||||
id: ct12Amps
|
||||
power:
|
||||
name: ${ct12_name} Watts
|
||||
name: ${ct12_name} ${watt_label}
|
||||
id: ct12Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal2}
|
||||
gain_ct: ${current_cal_ct12}
|
||||
line_frequency: ${electric_freq}
|
||||
@@ -79,9 +103,9 @@ sensor:
|
||||
enable_offset_calibration: ${offset_calibration}
|
||||
enable_gain_calibration: ${gain_calibration}
|
||||
|
||||
#Total Amps AddOn1
|
||||
#Total A AddOn1
|
||||
- platform: template
|
||||
name: ${friendly_name} Total Amps Add-on1
|
||||
name: Add-on 1 Total ${amp_label}
|
||||
id: totalAmpsAddOn1
|
||||
lambda: return id(ct7Amps).state + id(ct8Amps).state + id(ct9Amps).state + id(ct10Amps).state + id(ct11Amps).state + id(ct12Amps).state ;
|
||||
accuracy_decimals: 2
|
||||
@@ -89,12 +113,78 @@ sensor:
|
||||
device_class: current
|
||||
update_interval: ${update_time}
|
||||
|
||||
#Total Watts AddOn1
|
||||
#Total W AddOn1
|
||||
- platform: template
|
||||
name: ${friendly_name} Total Watts Add-on1
|
||||
name: Add-on 1 Total ${watt_label}
|
||||
id: totalWattsAddOn1
|
||||
lambda: return id(ct7Watts).state + id(ct8Watts).state + id(ct9Watts).state + id(ct10Watts).state + id(ct11Watts).state + id(ct12Watts).state ;
|
||||
accuracy_decimals: 2
|
||||
unit_of_measurement: W
|
||||
device_class: power
|
||||
update_interval: ${update_time}
|
||||
|
||||
#kWh From CT 7
|
||||
- platform: total_daily_energy
|
||||
name: ${ct7_name} ${kwh_label}
|
||||
id: ct7Kwh
|
||||
power_id: ct7Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
|
||||
# kWh from CT 8
|
||||
- platform: total_daily_energy
|
||||
name: ${ct8_name} ${kwh_label}
|
||||
id: ct8Kwh
|
||||
power_id: ct8Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
|
||||
#kWh From CT 9
|
||||
- platform: total_daily_energy
|
||||
name: ${ct9_name} ${kwh_label}
|
||||
id: ct9Kwh
|
||||
power_id: ct9Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
|
||||
#kWh From CT 10
|
||||
- platform: total_daily_energy
|
||||
name: ${ct10_name} ${kwh_label}
|
||||
id: ct10Kwh
|
||||
power_id: ct10Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
|
||||
#kWh From CT 11
|
||||
- platform: total_daily_energy
|
||||
name: ${ct11_name} ${kwh_label}
|
||||
id: ct11Kwh
|
||||
power_id: ct11Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
|
||||
#kWh From CT 12
|
||||
- platform: total_daily_energy
|
||||
name: ${ct12_name} ${kwh_label}
|
||||
id: ct12Kwh
|
||||
power_id: ct12Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
Reference in New Issue
Block a user