Single HomeAssistantService for all Taps

1. Amended code for a single HomeAssistantService for all 'tap's
2. Removed now redundant GET request for taps without a service now that having a service is enforced.
3. Determined that migrating API code from 'toggle's to the HomeAssistantService is awkward due to the close coupling with other methods in the class.
This commit is contained in:
Philip Abbey
2023-11-20 21:32:35 +00:00
parent bcdcfdc66c
commit ce90d9d47f
12 changed files with 136 additions and 150 deletions

View File

@ -24,17 +24,20 @@ using Toybox.Graphics;
using Toybox.Application.Properties;
class HomeAssistantIconMenuItem extends WatchUi.IconMenuItem {
hidden var mHomeAssistantService as HomeAssistantService;
private var mHomeAssistantService as HomeAssistantService;
private var mService as Lang.String;
// private var mIdentifier as Lang.String;
function initialize(
label as Lang.String or Lang.Symbol,
subLabel as Lang.String or Lang.Symbol or Null,
label as Lang.String or Lang.Symbol,
subLabel as Lang.String or Lang.Symbol or Null,
identifier as Lang.Object or Null,
service as Lang.String or Null,
icon as Graphics.BitmapType or WatchUi.Drawable,
options as {
service as Lang.String or Null,
icon as Graphics.BitmapType or WatchUi.Drawable,
options as {
:alignment as WatchUi.MenuItem.Alignment
} or Null
} or Null,
haService as HomeAssistantService
) {
WatchUi.IconMenuItem.initialize(
label,
@ -44,12 +47,13 @@ class HomeAssistantIconMenuItem extends WatchUi.IconMenuItem {
options
);
mHomeAssistantService = new HomeAssistantService(service, identifier);
mHomeAssistantService = haService;
mIdentifier = identifier;
mService = service;
}
function callService() as Void {
mHomeAssistantService.call();
mHomeAssistantService.call(mIdentifier as Lang.String, mService);
}
}