Fix for numeric menu items over Wi-Fi/LTE

Turns out the sync service will not run unless the picker has not only been popped but the display also updated.
This commit is contained in:
Philip Abbey
2025-11-07 09:05:22 +00:00
parent cc53b25508
commit 1e17d93310

View File

@@ -154,18 +154,16 @@ class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
//! @param b Ignored. It is included in order to match the expected function prototype of the callback method. //! @param b Ignored. It is included in order to match the expected function prototype of the callback method.
// //
function onConfirm(b as Lang.Boolean) as Void { function onConfirm(b as Lang.Boolean) as Void {
var dataAttribute = mPicker["data_attribute"]; var dataAttribute = mPicker["data_attribute"] as Lang.String?;
if (dataAttribute == null) { var entity_id = mData["entity_id"] as Lang.String?;
//return without call action if no data attribute is set to avoid crash
WatchUi.popView(WatchUi.SLIDE_RIGHT);
return;
}
var entity_id = mData["entity_id"];
if (entity_id == null) {
//return without call action if no entity_id is set to avoid crash
WatchUi.popView(WatchUi.SLIDE_RIGHT); WatchUi.popView(WatchUi.SLIDE_RIGHT);
WatchUi.requestUpdate();
if (dataAttribute == null or entity_id == null) {
// Return without service call if no data attribute or entity ID is set to avoid crash.
return; return;
} }
if (mAction != null) {
mHomeAssistantService.call( mHomeAssistantService.call(
mAction, mAction,
{ {
@@ -174,7 +172,7 @@ class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
}, },
mExit mExit
); );
WatchUi.popView(WatchUi.SLIDE_RIGHT); }
} }
//! Return a numeric menu item's fetch state template. //! Return a numeric menu item's fetch state template.
@@ -182,8 +180,9 @@ class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
//! @return A string with the menu item's template definition (or null). //! @return A string with the menu item's template definition (or null).
// //
function getNumericTemplate() as Lang.String? { function getNumericTemplate() as Lang.String? {
var entity_id = mData["entity_id"]; var entity_id = mData["entity_id"] as Lang.String?;
var attribute = mPicker["attribute"] as Lang.String?; var attribute = mPicker["attribute"] as Lang.String?;
if (entity_id == null) { if (entity_id == null) {
return null; return null;
} else { } else {