Skip to content

Commit

Permalink
Remove duplicate sensors on single phase HomeWizard meters (home-assi…
Browse files Browse the repository at this point in the history
…stant#104493)

Co-authored-by: Duco Sebel <[email protected]>
  • Loading branch information
frenck and DCSBL authored Nov 26, 2023
1 parent 4a5b1ab commit 32eab2c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 488 deletions.
12 changes: 10 additions & 2 deletions homeassistant/components/homewizard/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ class HomeWizardSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
has_fn=lambda data: data.total_energy_import_t1_kwh is not None,
has_fn=lambda data: (
# SKT/SDM230/630 provides both total and tariff 1: duplicate.
data.total_energy_import_t1_kwh is not None
and data.total_energy_export_t2_kwh is not None
),
value_fn=lambda data: data.total_energy_import_t1_kwh,
),
HomeWizardSensorEntityDescription(
Expand Down Expand Up @@ -160,7 +164,11 @@ class HomeWizardSensorEntityDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
has_fn=lambda data: data.total_energy_export_t1_kwh is not None,
has_fn=lambda data: (
# SKT/SDM230/630 provides both total and tariff 1: duplicate.
data.total_energy_export_t1_kwh is not None
and data.total_energy_export_t2_kwh is not None
),
enabled_fn=lambda data: data.total_energy_export_t1_kwh != 0,
value_fn=lambda data: data.total_energy_export_t1_kwh,
),
Expand Down
Loading

0 comments on commit 32eab2c

Please sign in to comment.