Skip to content

Commit

Permalink
remove the clean_config service as it's not required any more with th…
Browse files Browse the repository at this point in the history
…e now-possible device deletion.

add capability to reload integration

docs
gluap committed Dec 31, 2023

Verified

This commit was signed with the committer’s verified signature.
gluap gluap
1 parent 1506611 commit 7480585
Showing 2 changed files with 8 additions and 32 deletions.
9 changes: 5 additions & 4 deletions custom_components/duofern/__init__.py
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
"""Unload deCONZ config entry."""

stick = getDuofernStick(hass)
stick.sync_devices()
stick.stop()
try:
stick.serial_connection.close()
@@ -174,8 +175,8 @@ def start_unpairing(call: ServiceCall) -> None:
_LOGGER.warning("start pairing")
getDuofernStick(hass).unpair(call.data.get('timeout', 60))

# def sync_devices(call: ServiceCall) -> None:
# stick.sync_devices()
def sync_devices(call: ServiceCall) -> None:
stick.sync_devices()

def dump_device_state(call: ServiceCall) -> None:
_LOGGER.warning(getDuofernStick(hass).duofern_parser.modules)
@@ -250,8 +251,8 @@ def set_update_interval(call: ServiceCall) -> None:

hass.services.register(DOMAIN, 'start_pairing', start_pairing, PAIRING_SCHEMA)
hass.services.register(DOMAIN, 'start_unpairing', start_unpairing, PAIRING_SCHEMA)
# hass.services.register(DOMAIN, 'sync_devices', sync_devices)
hass.services.register(DOMAIN, 'clean_config', clean_config)
hass.services.register(DOMAIN, 'sync_devices', sync_devices)
#hass.services.register(DOMAIN, 'clean_config', clean_config)
hass.services.register(DOMAIN, 'dump_device_state', dump_device_state)
hass.services.register(DOMAIN, 'ask_for_update', ask_for_update, UPDATE_SCHEMA)
hass.services.register(DOMAIN, 'set_update_interval', set_update_interval, UPDATE_INTERVAL_SCHEMA)
31 changes: 3 additions & 28 deletions readme.md
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ To use ``pyduofern`` within [Homeassistant](https://home-assistant.io/), add the

There are some services you can call via the service interface. A few of these to get you started:

``duofern.start_pairing`` starts the pairing mode for a given number of seconds.
``duofern.start_pairing`` starts the pairing mode for a given number of seconds. After pairing reload the integration to make the new devices visible.

![Pairing](./pairing.png)

@@ -54,30 +54,5 @@ Ask duofern devices to re-send their state in case. Can be used in setups where
``duofern.dump_device_state``
Dump the current last received state for all duofern modules as a warning level message to the log. This reflects the current state of all RF messages received from devices - What's not here wasn't received by the stick or came in garbled.

``duofern.clean_config``
> **Warning**
> You should absolutely NOT use it if you have been running duofern for a long time and your covers have "human" names in the .duofern.json file. That option hasn't been used for a long time though - it is still from the time when homeassistant had no UI way of renaming entities/devices.
**Use when:**
- you have "ghost" devices that do not correspond to a physical device

**Use like this:**
- If you want to be sure you can go back: backup ``duofern.json``.
- Call ``duofern.clean_config``.
- Restart homeassistant.
- Observe that all your duofern devices are now disabled/unavailable.
- Toggle/move all your duofern devices at the device to make sure that they send messages for homeassistant to pick up.
- You can diagnose what devices were picked up again using ``duofern.dump_device_state``.
- Once all devices are there: call ``duofern.sync_devices``.
- Restart homeassistant for good measure.
- Observe that the devices are now back.
- If some are still missing: toggle them at the device and diagnose using ``dump_device_state`` until they are found again.
- Once they are: ``duofern.sync_devices``, final restart.
- Everything works.
- If not: maybe you want to return to your backed-up ``duofern.json``.

The duofern python module keeps a list of devices that are paired. ``clean_config`` throws that list away.

In normal operation, the list should rebuild itself - whenever a message is received from a device that was previously paired it should appear in the list.
It's not very well tested because it's not a common situation. I ran it, restarted homeassistant, and my devices became available again after a few seconds.

``duofern.sync_devices``
Write the duofern config file with the known devices. normally not required from the user.

0 comments on commit 7480585

Please sign in to comment.