Skip to content

Commit

Permalink
- More verbosity in "ask_for_update"
Browse files Browse the repository at this point in the history
- Use updated duofern to avoid issues with ghost devices
- More description in services.yaml
  • Loading branch information
gluap committed Apr 2, 2023
1 parent c062a8a commit 2283d72
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
9 changes: 7 additions & 2 deletions custom_components/duofern/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,22 @@ def get_device_id(hass_entity_id):
get_all = call.data.get('all', None)
hass_device_id = call.data.get('device_id', None)
if get_all:
device_ids = hass.data[DOMAIN]['stick'].duofern_parser.modules['by_code']
_LOGGER.info("Asking all devices for update")
device_ids = hass.data[DOMAIN]['stick'].duofern_parser.modules['by_code'].keys()
else:
_LOGGER.info("Asking specific devices for update")
device_ids = [get_device_id(i) for i in hass_device_id]
except Exception:
_LOGGER.exception(f"exception while getting device id {call}, {call.data}, i konw {hass.data[DOMAIN]['deviceByHassId']}, fyi deviceByID is {hass.data[DOMAIN]['devices']}")
_LOGGER.exception(f"Exception while getting device id {call}, {call.data}, i know {hass.data[DOMAIN]['deviceByHassId']}, fyi deviceByID is {hass.data[DOMAIN]['devices']}")
for id,dev in hass.data[DOMAIN]['deviceByHassId'].items():
_LOGGER.warning(f"{id}, {dev.__dict__}")
raise
if device_ids is None:
_LOGGER.warning(f"device_id missing from call {call.data}")
return
_LOGGER.info(f"Updating these devices {' '.join(device_ids)}")
if not device_ids or all([i is None for i in device_ids]):
_LOGGER.warning("Found no valid device ids???")
for device_id in device_ids:
if device_id is not None:
if device_id not in hass.data[DOMAIN]['stick'].duofern_parser.modules['by_code']:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/duofern/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"config_flow": true,
"issue_tracker": "https://github.com/gluap/pyduofern-hacs/issues" ,
"codeowners": ["@gluap"],
"requirements": ["pyduofern==0.35.1"],
"requirements": ["pyduofern==0.35.2"],
"version": "0.5.2"
}
18 changes: 13 additions & 5 deletions custom_components/duofern/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,26 @@ start_pairing:
example: 60

sync_devices:
description: re-sync devices (trigger after pairing, if it does not work, a restart of homeassistant may help)
description: Re-sync Devices (trigger after pairing, if it does not work, a restart of homeassistant may help)

clean_config:
description: Clean the duofern config. Will erase all devices from duofern config.
Paired devices should automatically be re-added after when they speak to duofern stick.
Non-Paired bogous devices not. **Use with caution - not tested.**
If you want to be sure manually edit ``.duofern.json`` and remove unwanted devices there
Be aware that homeassistant might keep its own record of these unwanted devices - you
have to deall with these via homeassistant GUI.

dump_device_state:
description: dump state of all known devices as a warning. State reflects state considering all
messages received from devices (independent from homeassistant device state).
Purpose is to debug whether there's a discrepancy with state reflected in Homeassistant.

ask_for_update:
description: ask the specified device for an update (in case of missed radio transmissions)
description: Ask the specified device for an update (in case of missed radio transmissions).
fields:
all:
description: update all devices
description: Update all devices.
required: false
selector:
boolean:
Expand All @@ -33,9 +41,9 @@ ask_for_update:
integration: duofern

set_update_interval:
description: set the automatically broadcasting a "please send an update" interval.
description: Set the automatically broadcasting a "please send an update" interval.
Be aware that this is not persisted. Use an automation to trigger this at Homeassistant
start if you always want it to be set to your custom value
start if you always want it to be set to your custom value.
fields:
period_minutes:
description: approximate forced refresh interval in minutes - defaults to 5, 0 means never
Expand Down

0 comments on commit 2283d72

Please sign in to comment.