Skip to content

Commit

Permalink
Add Water Heater dedicate polling (#428)
Browse files Browse the repository at this point in the history
This will implement the same logic used in AC device to have valid updates for  energy usage. A new Energy Current sensor is availble for the device.
  • Loading branch information
ollo69 committed Dec 11, 2022
1 parent 75cf0b5 commit 0bc707b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion custom_components/smartthinq_sensors/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Constants for LGE ThinQ custom componet."""

__version__ = "0.25.1"
__version__ = "0.25.2b1"
PROJECT_URL = "https://github.com/ollo69/ha-smartthinq-sensors/"
ISSUE_URL = f"{PROJECT_URL}issues"

Expand Down
2 changes: 1 addition & 1 deletion custom_components/smartthinq_sensors/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
],
"config_flow": true,
"iot_class": "cloud_polling",
"version": "0.25.1"
"version": "0.25.2b1"
}
7 changes: 7 additions & 0 deletions custom_components/smartthinq_sensors/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,13 @@ class ThinQSensorEntityDescription(SensorEntityDescription):
unit_fn=lambda x: x.temp_unit,
entity_registry_enabled_default=False,
),
ThinQSensorEntityDescription(
key=FEAT_ENERGY_CURRENT,
name="Energy current",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT,
),
)


Expand Down
14 changes: 7 additions & 7 deletions custom_components/smartthinq_sensors/wideq/waterheater.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,17 @@ def reset_status(self):
# # this command is to get power usage on V1 device
# self._current_power = await self.get_power()

# async def _pre_update_v2(self):
# """Call additional methods before data update for v2 API."""
# # this command is to get power and temp info on V2 device
# keys = self._get_cmd_keys(CMD_ENABLE_EVENT_V2)
# await self.set(keys[0], keys[1], key=keys[2], value="70", ctrl_path="control")
async def _pre_update_v2(self):
"""Call additional methods before data update for v2 API."""
# this command is to get power and temp info on V2 device
keys = self._get_cmd_keys(CMD_ENABLE_EVENT_V2)
await self.set(keys[0], keys[1], key=keys[2], value="70", ctrl_path="control")

async def poll(self) -> Optional["WaterHeaterStatus"]:
"""Poll the device's current state."""
res = await self.device_poll(
thinq1_additional_poll=0, # ADD_FEAT_POLL_INTERVAL,
thinq2_query_device=False, # True,
thinq2_query_device=True,
)
if not res:
return None
Expand Down Expand Up @@ -304,7 +304,7 @@ def energy_current(self):
"""Return current energy usage."""
key = self._get_state_key(STATE_POWER)
value = self._data.get(key)
if value is not None and self.is_info_v2 and not self.is_on:
if value is not None and self.is_info_v2:
# decrease power for V2 device that always return 50 when standby
new_value = self.to_int_or_none(value)
if new_value and new_value <= 50:
Expand Down

0 comments on commit 0bc707b

Please sign in to comment.