-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Plugin accessories not updating after refresh, need development guidance. #3529
Comments
@mrjackyliang I use this feature with most of my plugins, and to enable it, do not implement the onGet() and on('get') interface and only use updateValue() or updateCharacteristic() |
Will try this method out, thank you!! |
@NorthernMan54 Just to further clarify, will I continue to to use the onSet method, or change that as well? Would be awesome if I can see an example |
Thanks! Will close this off for now, and if there are more issues, I'll ask here :) |
I made the changes, but this didn't seem to work. My accessories remain in a frozen state. If I change the system from Off to Home, the Security Panel remains at Off. Weird. |
If you enable HAP-NodeJS debug mode, you can see the messages between the Home App and HomeKit, this may help with digging into the issue HAP-NodeJS DEBUG mode is explained here https://github.com/homebridge/HAP-NodeJS/wiki/FAQ |
Will read through it, thanks! |
So I'm looking through the logs, not sure what I'm looking for, but this seems interesting:
This happened after a force refresh when I didn't see the system armed. Now the question is, why isn't HomeKit getting notifications? I also see this happening all the time, right after it finishes retrieving:
|
Here is a sample debug log from my Tasmota plugin when I locally control the light switch. The relevant line of code is here - https://github.com/NorthernMan54/homebridge-tasmota/blob/473f4e593ff3d8d92710e9aa4b318f9dd7946f29/src/tasmotaLightService.ts#L221
For this I created a simple Home in the home app with only one accessory, a lamp. |
I have a feeling I need to read into MQTT first. Something is causing the connection between HAP and the Homebridge server to close. |
The MQTT here is just the messages received between my device and plugin, and is only relevant to see what is happening there. Besides that detail, it can be ignored. If the connection is closing you may have a local network issue or iPhone sleeping or ? Typically the Home app drops the connection when the app closes etc, and opens it again when then the app opens. |
Which is weird, you know. The app is open next to me, and the app doesn't change at all until I close and open it. However, I haven't tried all of the scenarios yet (like keeping the app closed, my phone asleep, and changing my security system through an external source). But for local network issues, any pointers for what I should be looking for? |
I think you may have a fundamental design issue with your plugin How does your plugin receive status updates from the device, and what does it do with the data ? There are two design patterns for plugins, one for devices that push status changes ( my tasmota plugin ) and one the pulls or polls the status from the device. What does your device/plugin do ? With updateValue, this needs to put into the status change code, and the updated value pushed to HomeKit. |
I don't doubt that. There's always something missing somewhere🥲 The plugin starts with the platform, where the plugin initializes the API, and starts the syncing. The information is pulled based on the sync code changes, and all of that information is stored in the platform's "state" (some object in that class). Once that's done, the plugin determines if the current accessory exists or not. If it doesn't, it executes Both add and update accessories initiate an instance of an Accessory class just like how the examples do it. I just get stuck wondering if I might need some public method to force accessories to update. |
It should be simple, does you plugin pull status updates or does the device push status updates ? If it pulls, then as part of the pull polling loop you need to updateValue for each change. If it pushes, then as part of the push event listener, once you determine which accessory it is, then updateValue. |
In the process of implementing the methods! |
Yeah implementing the
|
If you can help me point out what I'm not doing correctly, here's the latest updated file: https://github.com/mrjackyliang/homebridge-adt-pulse/blob/main/src/lib/accessory.ts |
Actually it seems to work now. Okay, I don't know what went wrong, but I literally tried everything! |
So what I discovered from all this is every time I fetch a status, I need to use both The I think the part why But so far, I seem to understand Homebridge more now, and this can be used as a reference who happen to come across the same problem as me! Thanks for the guidance, @NorthernMan54! |
One other comment, updateValue caches the value within Homebridge ( actually HAP-NodeJS ), and when the Home App is closed/opened the cached values are returned. Greatly increasing the overall response time of the plugin. You should be able to architect the plugin to not use |
I did try removing onGet earlier, it returned mixed responses (sometimes it would show the status, sometimes it won't). As far as I know, it should simply return the cached value, but for some reason, updateValue works if the onGet is there as well. |
@NorthernMan54 Just coming back to tell you the plugin now works without Thank you!! |
That is awesome, Tks for adding this to the available plugins |
Current Situation
Hello, I am re-writing a security system plugin and what I noticed is that all the accessories don't update until I close the Home app, or switch pages and have the app refresh itself. I tried a few methods, both with no luck.
Methods I've used:
onGet()
on('get')
updateValue()
updateCharacteristic()
A small snippet on how I fetch contact sensors:
A small snippet on how I set the security panel:
If anyone has come across this issue, please do let me know, thanks! Or if you require more code, please do let me know!
Logs
Configuration
N/A
Environment
Process Supervisor
not applicable
Additional Context
No response
The text was updated successfully, but these errors were encountered: