Skip to content

Commit

Permalink
remove unused sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
MadOne committed Oct 18, 2024
1 parent 2f5c516 commit 9cec36c
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 27 deletions.
96 changes: 71 additions & 25 deletions custom_components/weishaupt_modbus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,44 @@ async def async_setup_entry(
"""Set up the sensor platform."""
host = config_entry.data[CONF_HOST]
port = config_entry.data[CONF_PORT]
myWp = wp.heat_pump(host, port)
myWp.connect()
myList = [
Sys_Aussentemperatur1(host, port),
Sys_Aussentemperatur2(host, port),
Sys_Fehler(host, port),
Sys_Warnung(host, port),
Sys_Fehlerfrei(host, port),
Sys_Betriebsanzeige(host, port),
HK_RaumSollTemperatur(host, port),
# HK_RaumTemperatur(host, port),
# HK_RaumFeuchte(host, port),
HK_VorlaufSollTemperatur(host, port),
# HK_VorlaufTemperatur(host, port),
sensor_measured_temp(host, port),
sensor_target_temp(host, port),
Energy_today(host, port),
Energy_yesterday(host, port),
Energy_month(host, port),
Energy_year(host, port),
HP_Betrieb(host, port),
HP_Stoermeldung(host, port),
HP_Leistungsanforderung(host, port),
Hp_Vorlauftemperatur(host, port),
Hp_Ruecklauftemperatur(host, port),
WW_Konfiguration(host, port),
# EnergySensor(myWp, "testname", "testdevice", myWp.Energy_total_year),
# EnergySensor(myWp, "testname2", "testdevice2", myWp.Energy_total_year),
]
if myWp.HK_Raumfeuchte is not None:
myList.append(HK_RaumFeuchte(host, port))
if myWp.HK_Raumtemperatur is not None:
myList.append(HK_RaumTemperatur(host, port))
if myWp.HK_Vorlauftemperatur is not None:
myList.append(HK_VorlaufTemperatur(host, port))

async_add_entities(
[
Sys_Aussentemperatur1(host, port),
Sys_Aussentemperatur2(host, port),
Sys_Fehler(host, port),
Sys_Warnung(host, port),
Sys_Fehlerfrei(host, port),
Sys_Betriebsanzeige(host, port),
HK_RaumSollTemperatur(host, port),
HK_RaumTemperatur(host, port),
HK_RaumFeuchte(host, port),
HK_VorlaufSollTemperatur(host, port),
HK_VorlaufTemperatur(host, port),
sensor_measured_temp(host, port),
sensor_target_temp(host, port),
Energy_today(host, port),
Energy_yesterday(host, port),
Energy_month(host, port),
Energy_year(host, port),
HP_Betrieb(host, port),
HP_Stoermeldung(host, port),
HP_Leistungsanforderung(host, port),
Hp_Vorlauftemperatur(host, port),
Hp_Ruecklauftemperatur(host, port),
WW_Konfiguration(host, port),
],
myList,
update_before_add=True,
)

Expand Down Expand Up @@ -838,3 +850,37 @@ def device_info(self) -> DeviceInfo:
return {
"identifiers": {(DOMAIN, "Statistik")},
}


class EnergySensor(SensorEntity):
"""Representation of a Sensor."""

_attr_name = ""
_attr_unique_id = ""
_attr_should_poll = True
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
_attr_device_class = SensorDeviceClass.ENERGY

def __init__(self, myWp, name, device, method) -> None:
"""Init."""
self._myWp = myWp
self._attr_name = name
self._attr_unique_id = DOMAIN + self._attr_name
self._device = device
# self._method = method()

async def async_update(self) -> None:
"""Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
"""

self._myWp.connect()
self._attr_native_value = 21

@property
def device_info(self) -> DeviceInfo:
"""Information about this entity/device."""
return {
"identifiers": {(DOMAIN, self._device)},
}
8 changes: 6 additions & 2 deletions custom_components/weishaupt_modbus/wp.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,17 @@ def Cooling_total_year(self):
"""Energy used for cooling year."""
return self.WWP.read_input_registers(36404, slave=1).registers[0]

def Selector(self, methodToRun):
"""Selector to pass to Objects."""
return methodToRun()

# whp = heat_pump(hp_ip, hp_port)

# whp = heat_pump("10.10.1.225", "502")
# whp.connect()
# print(whp.WW_Soll)
# whp.WW_Soll = 44
# print(whp.WW_Soll)
# whp.WW_Soll = 45
# print(whp.WW_Soll)

# print(whp.WW_Ist)
# print(whp.HK_Raumfeuchte)

0 comments on commit 9cec36c

Please sign in to comment.