mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-16 19:38:34 +00:00
More responsive status when using a polling delay
When using a polling delay, an action will trigger an immediate round of updates.
This commit is contained in:
@ -408,6 +408,20 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
}
|
||||
}
|
||||
|
||||
// Only call this function if Settings.getPollDelay() > 0. This must be tested locally as it is then efficient to take
|
||||
// alternative action if the test fails.
|
||||
function forceStatusUpdates() as Void {
|
||||
// Don't mess with updates unless we are using a timer.
|
||||
if (Settings.getPollDelay() > 0) {
|
||||
mUpdateTimer.stop();
|
||||
mIsInitUpdateCompl = false;
|
||||
// Start from the beginning, or we will only get a partial round of updates before mIsInitUpdateCompl is flipped.
|
||||
mNextItemToUpdate = 0;
|
||||
// For immediate updates
|
||||
updateNextMenuItem();
|
||||
}
|
||||
}
|
||||
|
||||
// We need to spread out the API calls so as not to overload the results queue and cause Communications.BLE_QUEUE_FULL
|
||||
// (-101) error. This function is called by a timer every Globals.menuItemUpdateInterval ms.
|
||||
function updateNextMenuItemInternal() as Void {
|
||||
|
@ -80,6 +80,7 @@ class HomeAssistantService {
|
||||
|
||||
case 200:
|
||||
// System.println("HomeAssistantService onReturnCall(): Service executed.");
|
||||
getApp().forceStatusUpdates();
|
||||
var d = data as Lang.Array;
|
||||
var toast = WatchUi.loadResource($.Rez.Strings.Executed) as Lang.String;
|
||||
for(var i = 0; i < d.size(); i++) {
|
||||
|
@ -196,6 +196,8 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
||||
break;
|
||||
|
||||
case 200:
|
||||
// System.println("HomeAssistantToggleMenuItem onReturnSetState(): Service executed.");
|
||||
getApp().forceStatusUpdates();
|
||||
var state;
|
||||
var d = data as Lang.Array;
|
||||
for(var i = 0; i < d.size(); i++) {
|
||||
|
Reference in New Issue
Block a user