mirror of
				https://github.com/house-of-abbey/GarminHomeAssistant.git
				synced 2025-11-04 00:48:14 +00:00 
			
		
		
		
	Amending naming convention
Removing some inconsistencies
This commit is contained in:
		@@ -14,19 +14,23 @@
 | 
				
			|||||||
//
 | 
					//
 | 
				
			||||||
// Description:
 | 
					// Description:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Menu button with an icon that opens a sub-menu.
 | 
					// Menu button with an icon that opens a sub-menu, i.e. group.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//-----------------------------------------------------------------------------------
 | 
					//-----------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using Toybox.Lang;
 | 
					using Toybox.Lang;
 | 
				
			||||||
using Toybox.WatchUi;
 | 
					using Toybox.WatchUi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class HomeAssistantViewMenuItem extends WatchUi.IconMenuItem {
 | 
					class HomeAssistantGroupMenuItem extends WatchUi.IconMenuItem {
 | 
				
			||||||
    private var mMenu as HomeAssistantView;
 | 
					    private var mMenu as HomeAssistantView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function initialize(definition as Lang.Dictionary, icon as WatchUi.Drawable, options as {
 | 
					    function initialize(
 | 
				
			||||||
 | 
					        definition as Lang.Dictionary,
 | 
				
			||||||
 | 
					        icon       as WatchUi.Drawable,
 | 
				
			||||||
 | 
					        options    as {
 | 
				
			||||||
            :alignment as WatchUi.MenuItem.Alignment
 | 
					            :alignment as WatchUi.MenuItem.Alignment
 | 
				
			||||||
        } or Null) {
 | 
					        } or Null) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var label      = definition.get("name")   as Lang.String;
 | 
					        var label      = definition.get("name")   as Lang.String;
 | 
				
			||||||
        var identifier = definition.get("entity") as Lang.String;
 | 
					        var identifier = definition.get("entity") as Lang.String;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -123,7 +123,7 @@ class HomeAssistantMenuItemFactory {
 | 
				
			|||||||
        confirm    as Lang.Boolean,
 | 
					        confirm    as Lang.Boolean,
 | 
				
			||||||
        data       as Lang.Dictionary or Null
 | 
					        data       as Lang.Dictionary or Null
 | 
				
			||||||
    ) as WatchUi.MenuItem {
 | 
					    ) as WatchUi.MenuItem {
 | 
				
			||||||
        return new HomeAssistantMenuItem(
 | 
					        return new HomeAssistantTapMenuItem(
 | 
				
			||||||
            label,
 | 
					            label,
 | 
				
			||||||
            null,
 | 
					            null,
 | 
				
			||||||
            identifier,
 | 
					            identifier,
 | 
				
			||||||
@@ -137,6 +137,6 @@ class HomeAssistantMenuItemFactory {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function group(definition as Lang.Dictionary) as WatchUi.MenuItem {
 | 
					    function group(definition as Lang.Dictionary) as WatchUi.MenuItem {
 | 
				
			||||||
        return new HomeAssistantViewMenuItem(definition, mGroupTypeIcon, mMenuItemOptions);
 | 
					        return new HomeAssistantGroupMenuItem(definition, mGroupTypeIcon, mMenuItemOptions);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,7 +22,7 @@ using Toybox.Lang;
 | 
				
			|||||||
using Toybox.WatchUi;
 | 
					using Toybox.WatchUi;
 | 
				
			||||||
using Toybox.Graphics;
 | 
					using Toybox.Graphics;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class HomeAssistantMenuItem extends WatchUi.IconMenuItem {
 | 
					class HomeAssistantTapMenuItem extends WatchUi.IconMenuItem {
 | 
				
			||||||
    private var mHomeAssistantService as HomeAssistantService;
 | 
					    private var mHomeAssistantService as HomeAssistantService;
 | 
				
			||||||
    private var mService              as Lang.String;
 | 
					    private var mService              as Lang.String;
 | 
				
			||||||
    private var mConfirm              as Lang.Boolean;
 | 
					    private var mConfirm              as Lang.Boolean;
 | 
				
			||||||
@@ -14,7 +14,7 @@
 | 
				
			|||||||
//
 | 
					//
 | 
				
			||||||
// Description:
 | 
					// Description:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Rendering a Home Assistant Template.
 | 
					// Menu button that renders a Home Assistant Template, and optionally triggers a service.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Reference:
 | 
					// Reference:
 | 
				
			||||||
//  * https://developers.home-assistant.io/docs/api/rest/
 | 
					//  * https://developers.home-assistant.io/docs/api/rest/
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -87,7 +87,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
 | 
				
			|||||||
        var lmi = mItems as Lang.Array<WatchUi.MenuItem>;
 | 
					        var lmi = mItems as Lang.Array<WatchUi.MenuItem>;
 | 
				
			||||||
        for(var i = 0; i < mItems.size(); i++) {
 | 
					        for(var i = 0; i < mItems.size(); i++) {
 | 
				
			||||||
            var item = lmi[i];
 | 
					            var item = lmi[i];
 | 
				
			||||||
            if (item instanceof HomeAssistantViewMenuItem) {
 | 
					            if (item instanceof HomeAssistantGroupMenuItem) {
 | 
				
			||||||
                fullList.addAll(item.getMenuView().getItemsToUpdate());
 | 
					                fullList.addAll(item.getMenuView().getItemsToUpdate());
 | 
				
			||||||
            } else if (item instanceof HomeAssistantToggleMenuItem) {
 | 
					            } else if (item instanceof HomeAssistantToggleMenuItem) {
 | 
				
			||||||
                fullList.add(item);
 | 
					                fullList.add(item);
 | 
				
			||||||
@@ -150,8 +150,8 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
 | 
				
			|||||||
                System.println(haToggleItem.getLabel() + " " + haToggleItem.getId() + " " + haToggleItem.isEnabled());
 | 
					                System.println(haToggleItem.getLabel() + " " + haToggleItem.getId() + " " + haToggleItem.isEnabled());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            haToggleItem.setState(haToggleItem.isEnabled());
 | 
					            haToggleItem.setState(haToggleItem.isEnabled());
 | 
				
			||||||
        } else if (item instanceof HomeAssistantMenuItem) {
 | 
					        } else if (item instanceof HomeAssistantTapMenuItem) {
 | 
				
			||||||
            var haItem = item as HomeAssistantMenuItem;
 | 
					            var haItem = item as HomeAssistantTapMenuItem;
 | 
				
			||||||
            if (Globals.scDebug) {
 | 
					            if (Globals.scDebug) {
 | 
				
			||||||
                System.println(haItem.getLabel() + " " + haItem.getId());
 | 
					                System.println(haItem.getLabel() + " " + haItem.getId());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -162,8 +162,8 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
 | 
				
			|||||||
                System.println(haItem.getLabel() + " " + haItem.getId());
 | 
					                System.println(haItem.getLabel() + " " + haItem.getId());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            haItem.callService();
 | 
					            haItem.callService();
 | 
				
			||||||
        } else if (item instanceof HomeAssistantViewMenuItem) {
 | 
					        } else if (item instanceof HomeAssistantGroupMenuItem) {
 | 
				
			||||||
            var haMenuItem = item as HomeAssistantViewMenuItem;
 | 
					            var haMenuItem = item as HomeAssistantGroupMenuItem;
 | 
				
			||||||
            if (Globals.scDebug) {
 | 
					            if (Globals.scDebug) {
 | 
				
			||||||
                System.println("IconMenu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
 | 
					                System.println("IconMenu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user