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,7 +24,8 @@ using Toybox.Graphics;
using Toybox.Application.Properties;
class HomeAssistantMenuItem extends WatchUi.MenuItem {
hidden var mHomeAssistantService as HomeAssistantService;
private var mHomeAssistantService as HomeAssistantService;
private var mService as Lang.String;
function initialize(
label as Lang.String or Lang.Symbol,
@ -34,7 +35,8 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem {
options as {
:alignment as WatchUi.MenuItem.Alignment,
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol
} or Null
} or Null,
haService as HomeAssistantService
) {
WatchUi.MenuItem.initialize(
label,
@ -43,11 +45,12 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem {
options
);
mHomeAssistantService = new HomeAssistantService(service, identifier);
mHomeAssistantService = haService;
mService = service;
}
function callService() as Void {
mHomeAssistantService.call();
mHomeAssistantService.call(mIdentifier as Lang.String, mService);
}
}