Skip to content

Commit

Permalink
Implement Alarms (#60)
Browse files Browse the repository at this point in the history
* alarm implementation

* add script to cleanup logs for use with file mode

* fix for calybox

* implement device polling and refresh
  • Loading branch information
CyrilP authored Apr 19, 2024
1 parent a6858b4 commit fbd9710
Show file tree
Hide file tree
Showing 23 changed files with 810 additions and 203 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/[email protected].1"
uses: "actions/[email protected].2"

- name: "Set up Python"
uses: actions/setup-python@v5.0.0
uses: actions/setup-python@v5.1.0
with:
python-version: "3.10"
cache: "pip"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
contents: write
steps:
- name: "Checkout the repository"
uses: "actions/[email protected].1"
uses: "actions/[email protected].2"

- name: "Adjust version number"
shell: "bash"
Expand All @@ -30,6 +30,6 @@ jobs:
zip deltadore_tydom.zip -r ./
- name: "Upload the ZIP file to the release"
uses: softprops/[email protected].2
uses: softprops/[email protected].4
with:
files: ${{ github.workspace }}/custom_components/deltadore_tydom/deltadore_tydom.zip
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/[email protected].1"
uses: "actions/[email protected].2"

- name: "Run hassfest validation"
uses: "home-assistant/actions/hassfest@master"
Expand All @@ -27,7 +27,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/[email protected].1"
uses: "actions/[email protected].2"

- name: "Run HACS validation"
uses: "hacs/action@main"
Expand Down
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hass-deltadore-tydom-component</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ Platform | Description
**This integration has been tested with the following hardware.**

- Cover (Up/Down/Stop)
- Tywatt 5400
- Tywatt 5400, Tywatt 1000
- Tyxal+ DFR
- K-Line DVI (windows, door)
- Typass ATL (zones temperatures, target temperature, mode (Auto mode is used for antifrost), water/heat power usage) with Tybox 5101
- Calybox
- Tyxal+, Tyxal CSX40
- TYXIA 6610

Some other functions may also work or only report attributes.

Expand Down
36 changes: 33 additions & 3 deletions custom_components/deltadore_tydom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from homeassistant.exceptions import ConfigEntryNotReady

from . import hub
from .const import DOMAIN, CONF_TYDOM_PASSWORD
from .const import DOMAIN, CONF_TYDOM_PASSWORD, CONF_ZONES_HOME, CONF_ZONES_AWAY, CONF_REFRESH_INTERVAL

# List of platforms to support. There should be a matching .py file for each,
# eg <cover.py> and <sensor.py>
Expand All @@ -18,24 +18,43 @@
Platform.SENSOR,
Platform.LOCK,
Platform.LIGHT,
Platform.UPDATE
Platform.UPDATE,
Platform.ALARM_CONTROL_PANEL,
]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Delta Dore Tydom from a config entry."""

entry.async_on_unload(entry.add_update_listener(update_listener))

# Store an instance of the "connecting" class that does the work of speaking
# with your actual devices.
zone_home = None
if CONF_ZONES_HOME in entry.data:
zone_home = entry.data[CONF_ZONES_HOME]

zone_away = None
if CONF_ZONES_AWAY in entry.data:
zone_away = entry.data[CONF_ZONES_AWAY]

pin = None
if CONF_PIN in entry.data:
pin = entry.data[CONF_PIN]

refresh_interval = "30"
if CONF_REFRESH_INTERVAL in entry.data:
refresh_interval = entry.data[CONF_REFRESH_INTERVAL]

tydom_hub = hub.Hub(
hass,
entry,
entry.data[CONF_HOST],
entry.data[CONF_MAC],
entry.data[CONF_TYDOM_PASSWORD],
refresh_interval,
zone_home,
zone_away,
pin,
)
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = tydom_hub
Expand All @@ -49,7 +68,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
target=tydom_hub.ping(), hass=hass, name="Tydom ping"
)
entry.async_create_background_task(
target=tydom_hub.refresh_all(), hass=hass, name="Tydom refresh metadata and data"
target=tydom_hub.refresh_all(), hass=hass, name="Tydom refresh all metadata and data"
)
entry.async_create_background_task(
target=tydom_hub.refresh_data_1s(), hass=hass, name="Tydom refresh data 1s"
)
entry.async_create_background_task(
target=tydom_hub.refresh_data(), hass=hass, name="Tydom refresh data"
)

except Exception as err:
Expand All @@ -71,3 +96,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data[DOMAIN].pop(entry.entry_id)

return unload_ok

async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Update listener."""
tydom_hub = hass.data[DOMAIN][entry.entry_id]
tydom_hub.update_config(entry.data[CONF_REFRESH_INTERVAL], entry.data[CONF_ZONES_HOME], entry.data[CONF_ZONES_AWAY])
Loading

0 comments on commit fbd9710

Please sign in to comment.