-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update select.py for AIR_OUTSIDE_TPT #19
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -3,13 +3,21 @@ | |
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.helpers.entity import EntityCategory | ||
from homeassistant.helpers.entity_platform import AddEntitiesCallback | ||
from homeassistant.components.sensor import SensorEntity | ||
|
||
from .const import DOMAIN, PRODUCT_COORDINATORS | ||
from .entity import AldesProductDataUpdateCoordinator, AldesProductEntity | ||
|
||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback) -> None: | ||
coordinators = hass.data[DOMAIN][entry.entry_id][PRODUCT_COORDINATORS] | ||
async_add_entities(AldesProductEntityModeSelect(coordinator) for coordinator in coordinators) | ||
|
||
async_add_entities( | ||
[ | ||
AldesProductEntityModeSelect(coordinator) for coordinator in coordinators | ||
] + [ | ||
AldesProductOutsideTempSensor(coordinator) for coordinator in coordinators # Aggiungi il sensore per la temperatura esterna | ||
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. This sensor is not supported by all the products in https://github.com/aalmazanarbs/hassio_aldes/blob/master/aldes/product.py#L20, please, make it conditional and invoke 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. Please, change code comments to english. |
||
] | ||
) | ||
|
||
class AldesProductEntityModeSelect(AldesProductEntity, SelectEntity): | ||
|
||
|
@@ -29,3 +37,20 @@ def current_option(self) -> str: | |
async def async_select_option(self, option: str) -> None: | ||
await self.coordinator.product.maybe_set_mode_from_display(option) | ||
await self.coordinator.async_request_refresh() | ||
|
||
|
||
# Nuova classe per il sensore della temperatura esterna (AIR_OUTSIDE_TPT) | ||
class AldesProductOutsideTempSensor(AldesProductEntity, SensorEntity): | ||
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. Please, move this class and its |
||
|
||
_attr_icon = "mdi:thermometer" | ||
|
||
def __init__(self, coordinator: AldesProductDataUpdateCoordinator) -> None: | ||
super().__init__(coordinator, 'Outside Air Temperature') | ||
|
||
@property | ||
def native_value(self): | ||
return self.coordinator.product.air_outside_tpt # Restituisce il valore della temperatura esterna | ||
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. Remove this code comment, self explanatory with 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.
|
||
|
||
@property | ||
def native_unit_of_measurement(self): | ||
return "°C" | ||
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. Is it always |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create another
async_setup_entry
in the newsensor.py
file.