I have several plugins where I have implemented the TCPClient() protocol, including the Monoprice Multizone Controller (my foundation for this plugin is the plugin posted around the forum). The polling interval is set to 250. I know this has been asked a few times in both the old and new forums, but I am having trouble understanding exactly how the polling works.
I added a console.log() to the beginning of the onPoll function to see exactly what it is doing, and in most cases, it looks to run around 4 times, then does not run again. So, if I use a physical keypad to turn a zone on, the app is not picking it up, unless I refresh the app or it automatically refreshes itself (which seems to happen periodically if I change windows and go back to it?).
I feel like I have a fundamental misunderstanding of how polling works, or, it is possible that the Monoprice Controller does not report back state changes, so there is nothing for HR to receive.
Either way, this will be problematic if both my wife and I are using the app on our phones, but state changes are not synced. I am considering a couple different options here (which may be way overkill if I am misunderstanding how this is all working):
- Put a manual refresh button that will refresh the status of a device. This is not ideal, but I can for sure make this work.
- Automatically have the device refresh every XX seconds. This for sure is not ideal for network traffic but, again, would work.
- Set up one of my Raspberry Piās as a websocket server connected to the Monoprice Controller. It will poll the Monoprice periodically for changes (every 1 second?) and record them somehow. Then, set up a websocket connection from HR to that websocket server so state changes are announced.
The other devices I have use the HTTPClient() library, which also seem to get out of sync at times, but not as much as my TCPClient() devices.