mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-10-31 23:48:13 +00:00
Suggested code changes from philipabbey
1. attribute is option, so needs a different template in the API call when absent. 2. Automatically derive the format string from the picker step value for any precision of step. 3. Changed all Lang.String representations of numbers to Lang.Number or Lang.Float. I'm keen to remove the use of strings to hold a numeric value. 4. Tidied up and completed some code comments. 5. Adjusted the JSON schema definition. This is still not finished as the 'picker' object is required for 'numeric' menu items and must not be present for the others. Additional schema changes are required for greater precision. 6. Moved fields over from 'data' to 'picker'.
This commit is contained in:
@@ -127,18 +127,23 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
||||
));
|
||||
}
|
||||
} else if (type.equals("numeric") && service != null) {
|
||||
addItem(HomeAssistantMenuItemFactory.create().numeric(
|
||||
name,
|
||||
entity,
|
||||
content,
|
||||
service,
|
||||
data,
|
||||
{
|
||||
:exit => exit,
|
||||
:confirm => confirm,
|
||||
:pin => pin
|
||||
if (tap_action != null) {
|
||||
var picker = tap_action.get("picker") as Lang.Dictionary?;
|
||||
if (picker != null) {
|
||||
addItem(HomeAssistantMenuItemFactory.create().numeric(
|
||||
name,
|
||||
entity,
|
||||
content,
|
||||
service,
|
||||
picker,
|
||||
{
|
||||
:exit => exit,
|
||||
:confirm => confirm,
|
||||
:pin => pin
|
||||
}
|
||||
));
|
||||
}
|
||||
));
|
||||
}
|
||||
} else if (type.equals("info") && content != null) {
|
||||
// Cannot exit from a non-actionable information only menu item.
|
||||
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||
@@ -167,7 +172,6 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
||||
//!
|
||||
//! @return An array of menu items that need to be updated periodically to reflect the latest Home Assistant state.
|
||||
//
|
||||
|
||||
function getItemsToUpdate() as Lang.Array<HomeAssistantToggleMenuItem or HomeAssistantTapMenuItem or HomeAssistantGroupMenuItem or HomeAssistantNumericMenuItem or Null> {
|
||||
var fullList = [];
|
||||
var lmi = mItems as Lang.Array<WatchUi.MenuItem>;
|
||||
@@ -203,8 +207,8 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
||||
//! Called when this View is brought to the foreground. Restore
|
||||
//! the state of this View and prepare it to be shown. This includes
|
||||
//! loading resources into memory.
|
||||
//
|
||||
function onShow() as Void {}
|
||||
|
||||
}
|
||||
|
||||
//! Delegate for the HomeAssistantView.
|
||||
@@ -272,18 +276,13 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
||||
var haItem = item as HomeAssistantNumericMenuItem;
|
||||
// System.println(haItem.getLabel() + " " + haItem.getId());
|
||||
// create new view to select new value
|
||||
|
||||
var mPickerFactory = new HomeAssistantNumericFactory(haItem.getData());
|
||||
|
||||
var mPicker = new HomeAssistantNumericPicker(mPickerFactory,haItem);
|
||||
var mPickerFactory = new HomeAssistantNumericFactory((haItem as HomeAssistantNumericMenuItem).getPicker());
|
||||
var mPicker = new HomeAssistantNumericPicker(mPickerFactory,haItem);
|
||||
var mPickerDelegate = new HomeAssistantNumericPickerDelegate(mPicker);
|
||||
WatchUi.pushView(mPicker,mPickerDelegate,WatchUi.SLIDE_LEFT);
|
||||
} else if (item instanceof HomeAssistantGroupMenuItem) {
|
||||
var haMenuItem = item as HomeAssistantGroupMenuItem;
|
||||
// System.println("IconMenu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
|
||||
WatchUi.pushView(haMenuItem.getMenuView(), new HomeAssistantViewDelegate(false), WatchUi.SLIDE_LEFT);
|
||||
// } else {
|
||||
// System.println(item.getLabel() + " " + item.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user