-
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?
Conversation
|
||
|
||
# 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Please, move this class and its async_setup_entry
to a different class. Something like sensor.py
.
|
||
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( |
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 new sensor.py
file.
[ | ||
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 comment
The 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 async_add_entities
if the product support it.
[ | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Please, change code comments to english.
|
||
@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 comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this code comment, self explanatory with native_value
.
|
||
@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 comment
The reason will be displayed to describe this comment to others. Learn more.
air_outside_tpt
is not present in AldesProduct
, you must provide a way to get this value.
|
||
@property | ||
def native_unit_of_measurement(self): | ||
return "°C" |
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.
Is it always °C
? or it is configurable by Aldes App? If it is always in °C
ok, but take care of because °F
is also other possible value
No description provided.