mirror of
https://github.com/CeeWeasel/fresh-home.git
synced 2026-08-09 18:40:14 -04:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -5,34 +5,46 @@ sensor:
|
||||
#IC1 AddOn 2
|
||||
############
|
||||
- platform: atm90e32
|
||||
cs_pin: 27
|
||||
cs_pin: ${addon2_ic1}
|
||||
release_device: true
|
||||
id: ${addon2_id1}
|
||||
phase_a:
|
||||
current:
|
||||
name: ${ct13_name} Amps
|
||||
name: ${ct13_name} ${amp_label}
|
||||
id: ct13Amps
|
||||
power:
|
||||
name: ${ct13_name} Watts
|
||||
name: ${ct13_name} ${watt_label}
|
||||
id: ct13Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal1}
|
||||
gain_ct: ${current_cal_ct13}
|
||||
phase_b:
|
||||
current:
|
||||
name: ${ct14_name} Amps
|
||||
name: ${ct14_name} ${amp_label}
|
||||
id: ct14Amps
|
||||
power:
|
||||
name: ${ct14_name} Watts
|
||||
name: ${ct14_name} ${watt_label}
|
||||
id: ct14Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal1}
|
||||
gain_ct: ${current_cal_ct14}
|
||||
phase_c:
|
||||
current:
|
||||
name: ${ct15_name} Amps
|
||||
name: ${ct15_name} ${amp_label}
|
||||
id: ct15Amps
|
||||
power:
|
||||
name: ${ct15_name} Watts
|
||||
name: ${ct15_name} ${watt_label}
|
||||
id: ct15Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal1}
|
||||
gain_ct: ${current_cal_ct15}
|
||||
line_frequency: ${electric_freq}
|
||||
@@ -44,33 +56,45 @@ sensor:
|
||||
############
|
||||
- platform: atm90e32
|
||||
release_device: true
|
||||
cs_pin: 17
|
||||
cs_pin: ${addon2_ic2}
|
||||
id: ${addon2_id2}
|
||||
phase_a:
|
||||
current:
|
||||
name: ${ct16_name} Amps
|
||||
name: ${ct16_name} ${amp_label}
|
||||
id: ct16Amps
|
||||
power:
|
||||
name: ${ct16_name} Watts
|
||||
name: ${ct16_name} ${watt_label}
|
||||
id: ct16Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal2}
|
||||
gain_ct: ${current_cal_ct16}
|
||||
phase_b:
|
||||
current:
|
||||
name: ${ct17_name} Amps
|
||||
name: ${ct17_name} ${amp_label}
|
||||
id: ct17Amps
|
||||
power:
|
||||
name: ${ct17_name} Watts
|
||||
name: ${ct17_name} ${watt_label}
|
||||
id: ct17Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal2}
|
||||
gain_ct: ${current_cal_ct17}
|
||||
phase_c:
|
||||
current:
|
||||
name: ${ct18_name} Amps
|
||||
name: ${ct18_name} ${amp_label}
|
||||
id: ct18Amps
|
||||
power:
|
||||
name: ${ct18_name} Watts
|
||||
name: ${ct18_name} ${watt_label}
|
||||
id: ct18Watts
|
||||
filters:
|
||||
- lambda: |-
|
||||
if (x < 0) return x * -1;
|
||||
return x;
|
||||
gain_voltage: ${voltage_cal2}
|
||||
gain_ct: ${current_cal_ct18}
|
||||
line_frequency: ${electric_freq}
|
||||
@@ -79,9 +103,9 @@ sensor:
|
||||
enable_offset_calibration: ${offset_calibration}
|
||||
enable_gain_calibration: ${gain_calibration}
|
||||
|
||||
#Total Amps AddOn2
|
||||
#Total A AddOn2
|
||||
- platform: template
|
||||
name: ${friendly_name} Total Amps Add-on2
|
||||
name: Add-on 2 Total ${amp_label}
|
||||
id: totalAmpsAddOn2
|
||||
lambda: return id(ct13Amps).state + id(ct14Amps).state + id(ct15Amps).state + id(ct16Amps).state + id(ct17Amps).state + id(ct18Amps).state ;
|
||||
accuracy_decimals: 2
|
||||
@@ -89,12 +113,78 @@ sensor:
|
||||
device_class: current
|
||||
update_interval: ${update_time}
|
||||
|
||||
#Total Watts AddOn2
|
||||
#Total W AddOn2
|
||||
- platform: template
|
||||
name: ${friendly_name} Total Watts Add-on2
|
||||
name: Add-on 2 Total ${watt_label}
|
||||
id: totalWattsAddOn2
|
||||
lambda: return id(ct13Watts).state + id(ct14Watts).state + id(ct15Watts).state + id(ct16Watts).state + id(ct17Watts).state + id(ct18Watts).state ;
|
||||
accuracy_decimals: 2
|
||||
unit_of_measurement: W
|
||||
device_class: power
|
||||
update_interval: ${update_time}
|
||||
|
||||
#kWh From CT 13
|
||||
- platform: total_daily_energy
|
||||
name: ${ct13_name} ${kwh_label}
|
||||
id: ct13Kwh
|
||||
power_id: ct13Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
|
||||
# kWh from CT 14
|
||||
- platform: total_daily_energy
|
||||
name: ${ct14_name} ${kwh_label}
|
||||
id: ct14Kwh
|
||||
power_id: ct14Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
|
||||
#kWh From CT 15
|
||||
- platform: total_daily_energy
|
||||
name: ${ct15_name} ${kwh_label}
|
||||
id: ct15Kwh
|
||||
power_id: ct15Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
|
||||
#kWh From CT 16
|
||||
- platform: total_daily_energy
|
||||
name: ${ct16_name} ${kwh_label}
|
||||
id: ct16Kwh
|
||||
power_id: ct16Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
|
||||
#kWh From CT 17
|
||||
- platform: total_daily_energy
|
||||
name: ${ct17_name} ${kwh_label}
|
||||
id: ct17Kwh
|
||||
power_id: ct17Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
|
||||
#kWh From CT 18
|
||||
- platform: total_daily_energy
|
||||
name: ${ct18_name} ${kwh_label}
|
||||
id: ct18Kwh
|
||||
power_id: ct18Watts
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: kWh
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
Reference in New Issue
Block a user