Skip to content
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

[FIX] refactor dingz.updateAccessory #103

Closed
johannrichard opened this issue Nov 14, 2020 · 3 comments
Closed

[FIX] refactor dingz.updateAccessory #103

johannrichard opened this issue Nov 14, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@johannrichard
Copy link
Owner

Describe the enhancement
The updateAccessory() method of the dingz accessory needs refactoring:

  • integrate updating of the Accessory metadata (FW, Serial, Name etc.)
  • call DingzEvent.UPDATE_INFO to initiate an accessory Update
  • untangle some of the intertwined code snippets that doe (almost) the same thing e.g. in getDingzDeviceInfo() and platform.getDingzDeviceInfo

Examples and context

private async updateAccessory(): Promise<void> {
this.platform.log.info(
'Update accessory ',
this.device.address,
'-> Check for changed config.',
);
this.getConfigs().then(([inputConfig, dimmerConfig]) => {
if (inputConfig?.inputs[0]) {
this._updatedDeviceInputConfig = inputConfig.inputs[0];
}
this.device.dimmerConfig = dimmerConfig;
});
this.getDingzDeviceInfo().then((deviceInfo) => {
this._updatedDeviceInfo = deviceInfo;
});
let updatedDingzDeviceInfo: DingzDeviceInfo | undefined;
let updatedDingzInputInfo: DingzInputInfoItem | undefined;
try {
const currentDingzDeviceInfo: DingzDeviceInfo = this.accessory.context
.device.dingzDeviceInfo;
updatedDingzDeviceInfo =
this._updatedDeviceInfo ?? currentDingzDeviceInfo;
if (
currentDingzDeviceInfo &&
currentDingzDeviceInfo.has_pir !== updatedDingzDeviceInfo.has_pir
) {

@johannrichard johannrichard added the enhancement New feature or request label Nov 14, 2020
@johannrichard johannrichard self-assigned this Nov 14, 2020
@johannrichard johannrichard moved this from To do to In progress in Homebridge Plugin Nov 14, 2020
@johannrichard
Copy link
Owner Author

johannrichard commented Nov 21, 2020

Issues #116, #118, #120 and #123 are all related to the fact that this part of the code is still quite a mess.

I will therefore do two things:

  • Deprecate (or even remove) v1.8.0 of the extension (falling back to v1.7.1 which is working)
  • Refactor the code such that updates of the accessories and their states across all device types (i.e. myStrom and dingz)

I hope this will eventually solve these issues and cure the sick patient that v1.8.0 has become. 🤒🤕

@johannrichard
Copy link
Owner Author

Also of importance to all this:

homebridge/HAP-NodeJS#543

@johannrichard
Copy link
Owner Author

Things to be fixed in updateAccessory():

  • add / remove 'not_connected' dimmers
  • better / simpler handling of dimmers

Question: must we call this method really regularly or would it be sufficient to update on start?

johannrichard added a commit that referenced this issue Nov 22, 2020
- Add new event types
- Emit a `DingzEvent.REQUEST_STATE_UPDATE`
- Accessories subscribe to this instead of having their own timers
- Works towards [FIX] refactor dingz.updateAccessory #103
johannrichard added a commit that referenced this issue Nov 22, 2020
- will eventually integrate all `_config` functions into one method
- work towards [FIX] refactor dingz.updateAccessory #103
johannrichard added a commit that referenced this issue Nov 22, 2020
- Put device discovery back into the `dingz`
- Move to static discovery functions (`dingz`, `platform`)
- myStrom still need migration
- work [FIX] refactor dingz.updateAccessory #103
johannrichard added a commit that referenced this issue Nov 22, 2020
- fetching of config updates is much more robust and centralized
- updated firmware versions are now picked up reliably
- dingz accessory constructor is simplified
- Work towards implementing [FIX] refactor dingz.updateAccessory #103
johannrichard added a commit that referenced this issue Nov 28, 2020
- simplify device updates
- allows updating device info (core info) via platform
- implements (better) device recovery
- implements better error handling for devices
- streamlines code
- streamlines accessory interfaces & methods
- other small chores
- implements fixes #3, #103, #116, #123, #135
Homebridge Plugin automation moved this from In progress to Done Nov 29, 2020
johannrichard added a commit that referenced this issue Dec 5, 2020
- don't attempt any longer to catch all configuration changes
- should throw an unrecoverable error though
- update dimmer name changes
- fixes #103
johannrichard added a commit that referenced this issue Dec 12, 2020
- remove reference to #103, #116, #120, #123 (all implemented by now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

1 participant