-
-
Notifications
You must be signed in to change notification settings - Fork 38.3k
Add support for Inverter Pool Heat Pump (InverGo) #169606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
b61ddd6
0506c9b
daa3006
047c389
d27a7f6
049bb66
7cba841
f73ad26
ed0799a
0cf954b
127d73b
ed40a06
575ebef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| """Support for Tuya sensors.""" | ||
|
|
||
| from dataclasses import dataclass | ||
| from dataclasses import dataclass, replace | ||
|
|
||
| from tuya_device_handlers.definition.sensor import ( | ||
| SensorDefinition, | ||
|
|
@@ -38,6 +38,7 @@ | |
| UnitOfElectricPotential, | ||
| UnitOfEnergy, | ||
| UnitOfPower, | ||
| UnitOfTemperature, | ||
| UnitOfTime, | ||
| ) | ||
| from homeassistant.core import HomeAssistant, callback | ||
|
|
@@ -48,6 +49,7 @@ | |
| from .const import ( | ||
| DEVICE_CLASS_UNITS, | ||
| DOMAIN, | ||
| FAHRENHEIT_ALIASES, | ||
| LOGGER, | ||
| TUYA_DISCOVERY_NEW, | ||
| DeviceCategory, | ||
|
|
@@ -1613,12 +1615,42 @@ class TuyaSensorEntityDescription(SensorEntityDescription): | |
| ), | ||
| ), | ||
| DeviceCategory.ZNRB: ( | ||
| TuyaSensorEntityDescription( | ||
| key=DPCode.COMPRESSOR_STRENGTH, | ||
| translation_key="compressor_strength", | ||
|
tbouron marked this conversation as resolved.
|
||
| state_class=SensorStateClass.MEASUREMENT, | ||
|
epenet marked this conversation as resolved.
|
||
| native_unit_of_measurement=PERCENTAGE, | ||
|
tbouron marked this conversation as resolved.
Outdated
tbouron marked this conversation as resolved.
Outdated
tbouron marked this conversation as resolved.
Outdated
|
||
| ), | ||
| TuyaSensorEntityDescription( | ||
| key=DPCode.TEMP_AROUND, | ||
| translation_key="outside_temperature", | ||
|
tbouron marked this conversation as resolved.
|
||
| device_class=SensorDeviceClass.TEMPERATURE, | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
| ), | ||
|
tbouron marked this conversation as resolved.
|
||
| TuyaSensorEntityDescription( | ||
| key=DPCode.TEMP_COILER, | ||
| translation_key="coiler_temperature", | ||
|
tbouron marked this conversation as resolved.
Outdated
|
||
| device_class=SensorDeviceClass.TEMPERATURE, | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
| ), | ||
|
tbouron marked this conversation as resolved.
epenet marked this conversation as resolved.
|
||
| TuyaSensorEntityDescription( | ||
| key=DPCode.TEMP_CURRENT, | ||
| translation_key="temperature", | ||
| device_class=SensorDeviceClass.TEMPERATURE, | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
|
tbouron marked this conversation as resolved.
|
||
| ), | ||
| TuyaSensorEntityDescription( | ||
|
epenet marked this conversation as resolved.
|
||
| key=DPCode.TEMP_EFFLUENT, | ||
| translation_key="flow_temperature", | ||
|
tbouron marked this conversation as resolved.
|
||
| device_class=SensorDeviceClass.TEMPERATURE, | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
| ), | ||
|
tbouron marked this conversation as resolved.
|
||
| TuyaSensorEntityDescription( | ||
| key=DPCode.TEMP_VENTING, | ||
| translation_key="heat_exchanger_temperature", | ||
|
tbouron marked this conversation as resolved.
|
||
| device_class=SensorDeviceClass.TEMPERATURE, | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
| ), | ||
|
tbouron marked this conversation as resolved.
tbouron marked this conversation as resolved.
epenet marked this conversation as resolved.
|
||
| ), | ||
| DeviceCategory.ZWJCY: ( | ||
| TuyaSensorEntityDescription( | ||
|
|
@@ -1647,6 +1679,19 @@ class TuyaSensorEntityDescription(SensorEntityDescription): | |
| SENSORS[DeviceCategory.PC] = SENSORS[DeviceCategory.KG] | ||
|
|
||
|
|
||
| def _get_temp_unit_from_device( | ||
| device: CustomerDevice, | ||
| ) -> UnitOfTemperature | None: | ||
| """Return the temperature unit reported by the device via TEMP_UNIT_CONVERT, or None.""" | ||
| unit_value = device.status.get(DPCode.TEMP_UNIT_CONVERT) | ||
| if unit_value is None: | ||
| return None | ||
| unit_str = str(unit_value).lower() | ||
| if unit_str in FAHRENHEIT_ALIASES: | ||
| return UnitOfTemperature.FAHRENHEIT | ||
| return UnitOfTemperature.CELSIUS | ||
|
|
||
|
|
||
| async def async_setup_entry( | ||
| hass: HomeAssistant, | ||
| entry: TuyaConfigEntry, | ||
|
|
@@ -1662,17 +1707,27 @@ def async_discover_device(device_ids: list[str]) -> None: | |
| for device_id in device_ids: | ||
| device = manager.device_map[device_id] | ||
| if descriptions := SENSORS.get(device.category): | ||
| entities.extend( | ||
| TuyaSensorEntity(device, manager, description, definition) | ||
| for description in descriptions | ||
| if ( | ||
| temp_unit = _get_temp_unit_from_device(device) | ||
| for description in descriptions: | ||
| if not ( | ||
| definition := get_default_definition( | ||
| device, | ||
| description.dpcode or description.key, | ||
| description.wrapper_class, | ||
| ) | ||
| ): | ||
| continue | ||
| if ( | ||
| temp_unit is not None | ||
| and description.device_class == SensorDeviceClass.TEMPERATURE | ||
| and description.native_unit_of_measurement is None | ||
| ): | ||
| description = replace( | ||
| description, native_unit_of_measurement=temp_unit | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #170338 - which I think should be merged first. I think this should then be handled inside
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aha, that makes sense. I'll rebase on your PR locally and make that change so it can be ready once yours is merged. Thank you @epenet |
||
| entities.append( | ||
| TuyaSensorEntity(device, manager, description, definition) | ||
| ) | ||
| ) | ||
|
|
||
| async_add_entities(entities) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.