-
Notifications
You must be signed in to change notification settings - Fork 17
Update sensor.py #153
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 sensor.py #153
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 |
|---|---|---|
|
|
@@ -131,6 +131,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_e | |
| entities.append( | ||
| OmniLogicChlorinatorSaltLevelSensorEntity(coordinator=coordinator, context=system_id, sensor_type="instant") | ||
| ) | ||
| entities.append( | ||
| OmniLogicChlorinatorSaltCellSensor(coordinator=coordinator, context=system_id) | ||
| ) | ||
|
|
||
| case ChlorinatorDispenserType.LIQUID: | ||
| # It looks like there are no liquid sensors exposed in the telemetry | ||
| pass | ||
|
|
@@ -270,6 +274,34 @@ def native_value(self) -> StateType | date | datetime | Decimal: | |
| def name(self) -> Any: | ||
| return f"{self.data.msp_config.name} {self._sensor_type.capitalize()} Salt Level" | ||
|
|
||
| class OmniLogicChlorinatorSaltCellSensor(OmniLogicEntity[EntityIndexChlorinator], SensorEntity): | ||
| def __init__(self, coordinator: OmniLogicCoordinator, context: int) -> None: | ||
| super().__init__(coordinator, context) | ||
|
|
||
| @property | ||
| def name(self) -> Any: | ||
| return f"{self.data.msp_config.name} Salt Cell Status" | ||
|
|
||
| @property | ||
| def native_value(self) -> StateType | date | datetime | Decimal: | ||
| is_on = (self.data.telemetry.status_raw & 0b00000100) != 0 | ||
| is_init = (self.data.telemetry.status_raw & 0b00000010) != 0 | ||
|
Owner
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 bit does not indicate that the salt cell is in an initialization state, it indicates that there is an alert value present. You would then need to reference the value of chlrAlert from the telemetry to determine what alert is present. Likewise bit 0 indicates an error is present and you would then reference chlrError from the telemetry to see what error is present. |
||
| polarity_k1 = (self.data.telemetry.status_raw & 0b01000000) != 0 | ||
| polarity_k2 = (self.data.telemetry.status_raw & 0b10000000) != 0 | ||
|
Owner
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. As mentioned above, I would prefer this parsing happen in the underlying library and then be exposed as attributes for the on/off sensor indicating which relay is active. |
||
|
|
||
| if not is_on: | ||
| return "OFF" | ||
|
|
||
| if not is_init: | ||
| return "Init" | ||
|
|
||
| if polarity_k1: | ||
| return "K1" | ||
|
|
||
| if polarity_k2: | ||
| return "K2" | ||
|
|
||
| return self.data.telemetry.status_raw | ||
|
|
||
| class OmniLogicCSADAcidPhEntity(OmniLogicEntity[EntityIndexCSAD], SensorEntity): | ||
| _attr_device_class = SensorDeviceClass.PH | ||
|
|
||
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.
I would prefer that this parsing be done in the underlying library and then values be exposed to the integration from there.