Skip to content

Commit

Permalink
Initial Halo implementation. EQ implementation removed/broken
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNagy committed Jan 24, 2024
1 parent a8537c7 commit 8267986
Show file tree
Hide file tree
Showing 21 changed files with 464 additions and 287 deletions.
11 changes: 0 additions & 11 deletions .cookiecutter.json

This file was deleted.

1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2021 pbutterworth
Copyright (c) 2024 DanielNagy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,43 @@

[![BuyMeCoffee][buymecoffeebadge]][buymecoffee]

\**This component will set up the following platforms.**

| Platform | Description |
| --------------- | ------------------------------------------------------------------------- |
| `binary_sensor` | Show something `True` or `False`. |
| `sensor` | Show info from Astral Pool Viron eQuilibrium Chlorinator API. |
| `select` | Control the chlorinator mode (off/auto/manual) |
\*\*This component will set up the following platforms.\*\*

| Platform | Description |
| --------------- | ------------------------------------------------ |
| `binary_sensor` | Show something `True` or `False`. |
| `sensor` | Show info from Astral Pool Halo Chlorinator API. |
| `select` | Control the chlorinator mode (off/auto/manual) |

## Installation

1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`).
2. If you do not have a `custom_components` directory (folder) there, you need to create it.
3. In the `custom_components` directory (folder) create a new folder called `astralpool_chlorinator`.
4. Download _all_ the files from the `custom_components/astralpool_chlorinator/` directory (folder) in this repository.
3. In the `custom_components` directory (folder) create a new folder called `astralpool_halo_chlorinator`.
4. Download _all_ the files from the `custom_components/astralpool_halo_chlorinator/` directory (folder) in this repository.
5. Place the files you downloaded in the new directory (folder) you created.
6. Restart Home Assistant
7. Wait paitently for your chlorinator to be discovered (should only be a few seconds once HA has started up)
8. Upon discovery, you will need to manually enter Pair mode in the Halo's settings.

Using your HA configuration directory (folder) as a starting point you should now also have this:

```text
custom_components/astralpool_chlorinator/translations/en.json
custom_components/astralpool_chlorinator/translations/fr.json
custom_components/astralpool_chlorinator/translations/nb.json
custom_components/astralpool_chlorinator/translations/sensor.en.json
custom_components/astralpool_chlorinator/translations/sensor.fr.json
custom_components/astralpool_chlorinator/translations/sensor.nb.json
custom_components/astralpool_chlorinator/translations/sensor.nb.json
custom_components/astralpool_chlorinator/__init__.py
custom_components/astralpool_chlorinator/api.py
custom_components/astralpool_chlorinator/binary_sensor.py
custom_components/astralpool_chlorinator/config_flow.py
custom_components/astralpool_chlorinator/const.py
custom_components/astralpool_chlorinator/manifest.json
custom_components/astralpool_chlorinator/sensor.py
custom_components/astralpool_chlorinator/switch.py
custom_components/astralpool_halo_chlorinator/translations/en.json
custom_components/astralpool_halo_chlorinator/translations/fr.json
custom_components/astralpool_halo_chlorinator/translations/nb.json
custom_components/astralpool_halo_chlorinator/translations/sensor.en.json
custom_components/astralpool_halo_chlorinator/translations/sensor.fr.json
custom_components/astralpool_halo_chlorinator/translations/sensor.nb.json
custom_components/astralpool_halo_chlorinator/translations/sensor.nb.json
custom_components/astralpool_halo_chlorinator/__init__.py
custom_components/astralpool_halo_chlorinator/api.py
custom_components/astralpool_halo_chlorinator/binary_sensor.py
custom_components/astralpool_halo_chlorinator/config_flow.py
custom_components/astralpool_halo_chlorinator/const.py
custom_components/astralpool_halo_chlorinator/manifest.json
custom_components/astralpool_halo_chlorinator/sensor.py
custom_components/astralpool_halo_chlorinator/switch.py
```

## Configuration is done in the UI
Expand All @@ -59,6 +59,8 @@ custom_components/astralpool_chlorinator/switch.py

## Credits

This project was forked from [@pbutterworth](https://github.com/pbutterworth)'s' [AstralPool Chlorinator](https://github.com/pbutterworth/astralpool_chlorinator) with a future goal to merge both Halo and EQ together.

This project was generated from [@oncleben31](https://github.com/oncleben31)'s [Home Assistant Custom Component Cookiecutter](https://github.com/oncleben31/cookiecutter-homeassistant-custom-component) template.

Code template was mainly taken from [@Ludeeus](https://github.com/ludeeus)'s [integration_blueprint][integration_blueprint] template
Expand Down
106 changes: 0 additions & 106 deletions custom_components/astralpool_chlorinator/config_flow.py

This file was deleted.

5 changes: 0 additions & 5 deletions custom_components/astralpool_chlorinator/const.py

This file was deleted.

25 changes: 0 additions & 25 deletions custom_components/astralpool_chlorinator/manifest.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
from __future__ import annotations

import logging
from pychlorinator.chlorinator import ChlorinatorAPI

from bleak_retry_connector import get_device
from pychlorinator.chlorinator import ChlorinatorAPI
from pychlorinator.halochlorinator import HaloChlorinatorAPI

from homeassistant.components import bluetooth
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
Platform,
)
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_ADDRESS, Platform
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.const import (
CONF_ADDRESS,
CONF_ACCESS_TOKEN,
)
from homeassistant.exceptions import ConfigEntryNotReady

from .coordinator import ChlorinatorDataUpdateCoordinator
from .const import DOMAIN
from .coordinator import ChlorinatorDataUpdateCoordinator
from .models import ChlorinatorData

PLATFORMS: list[Platform] = [Platform.SENSOR, Platform.BINARY_SENSOR, Platform.SELECT]
Expand All @@ -38,7 +34,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
f"Could not find chlorinator device with address {address}"
)

chlorinator = ChlorinatorAPI(ble_device, accesscode)
_LOGGER.debug("async_setup_entry address: %s accesscode %s", address, accesscode)
if ble_device.name == "HCHLOR":
# true
chlorinator = HaloChlorinatorAPI(ble_device, accesscode)
else:
chlorinator = ChlorinatorAPI(ble_device, accesscode)

coordinator = ChlorinatorDataUpdateCoordinator(hass, chlorinator)
await coordinator.async_config_entry_first_refresh()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@

import logging

from homeassistant import config_entries
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
BinarySensorEntityDescription,
)
from homeassistant import config_entries
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
)
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .const import DOMAIN
from .coordinator import ChlorinatorDataUpdateCoordinator
from .models import ChlorinatorData
from .const import DOMAIN


_LOGGER = logging.getLogger(__name__)

Expand All @@ -30,33 +27,33 @@
icon="mdi:pump",
name="Pump",
),
"pump_is_priming": BinarySensorEntityDescription(
key="pump_is_priming",
device_class=BinarySensorDeviceClass.RUNNING,
icon="mdi:reload",
name="Pump priming",
),
"chemistry_values_current": BinarySensorEntityDescription(
key="chemistry_values_current",
icon="mdi:check-circle-outline",
name="Chemistry values current",
),
"chemistry_values_valid": BinarySensorEntityDescription(
key="chemistry_values_valid",
icon="mdi:check-circle",
name="Chemistry values valid",
),
# "pump_is_priming": BinarySensorEntityDescription(
# key="pump_is_priming",
# device_class=BinarySensorDeviceClass.RUNNING,
# icon="mdi:reload",
# name="Pump priming",
# ),
# "chemistry_values_current": BinarySensorEntityDescription(
# key="chemistry_values_current",
# icon="mdi:check-circle-outline",
# name="Chemistry values current",
# ),
# "chemistry_values_valid": BinarySensorEntityDescription(
# key="chemistry_values_valid",
# icon="mdi:check-circle",
# name="Chemistry values valid",
# ),
"cell_is_operating": BinarySensorEntityDescription(
key="cell_is_operating",
device_class=BinarySensorDeviceClass.RUNNING,
icon="mdi:fuel-cell",
name="Cell",
),
"sanitising_until_next_timer_tomorrow": BinarySensorEntityDescription(
key="sanitising_until_next_timer_tomorrow",
icon="mdi:fuel-cell",
name="Sanitising until next timer tomorrow",
),
# "sanitising_until_next_timer_tomorrow": BinarySensorEntityDescription(
# key="sanitising_until_next_timer_tomorrow",
# icon="mdi:fuel-cell",
# name="Sanitising until next timer tomorrow",
# ),
}


Expand Down Expand Up @@ -88,16 +85,16 @@ def __init__(
"""Initialize the sensor."""
super().__init__(coordinator)
self._sensor = sensor
self._attr_unique_id = f"POOL01_{sensor}".lower()
self._attr_unique_id = f"HCHLOR_{sensor}".lower()
self._attr_name = CHLORINATOR_BINARY_SENSOR_TYPES[sensor].name
self.entity_description = CHLORINATOR_BINARY_SENSOR_TYPES[sensor]
self._attr_device_class = CHLORINATOR_BINARY_SENSOR_TYPES[sensor].device_class

@property
def device_info(self) -> DeviceInfo | None:
return {
"identifiers": {(DOMAIN, "POOL01")},
"name": "POOL01",
"identifiers": {(DOMAIN, "HCHLOR")},
"name": "HCHLOR",
"model": "Viron eQuilibrium",
"manufacturer": "Astral Pool",
}
Expand Down
Loading

0 comments on commit 8267986

Please sign in to comment.