Giter Club home page Giter Club logo

garminhomeassistant's People

Contributors

j-a-n avatar jjusko avatar jose1711 avatar josephabbey avatar mymyke avatar patrick44fr avatar philipabbey avatar restyled-commits avatar someone0nearth avatar tarekbecker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

garminhomeassistant's Issues

Cache 'has' results

memory storage and widget suggests that has is an expensive operation and to perform the check once in initialize() and store the boolean as a member variable for the future.

We use has in several places where it is called repeated. Suggest we need to make a similar change.

Possiblity to add polling interval for states to save battery

As i have understood, the app "continuously" polls the Home Assistant API to see if a light has been turned on, the garage has been opened etc.

Would it be possible to add an option to change this, for the case of battery efficeny?

I've seen a drop in battery time on my Fenix 7X since installing the app, and i guess it's because of this, but this is all just assumptions, and the app may work a whole other way.

Thanks for a great app.

Error -400 - what did I do wrong?

Hello,
I found this app and I would really like to use it on my Venu 2.
When I then created the JSON file and entered all required data into the settings on the phone, I started the app on the watch and got Error Code -400.
What could I have done wrong?
20231205_170945
Best regards
Aaron Eisele

Battery reporting stops working when scrolling trough the widget

I have the application version installed on Fenix 7 Pro
I've set up the battery reporting and it worked fine, the issue occured if I add the homeassistant widget in my widget list and scroll through the homeassistant widget (where it shows "Homeassistant API: available Menu: available"), the background battery reporting will stop, I need to run the homeassitant application again to restart the reporting

Separate phone connection test from connection available test

There are 4 instances of this test:

System.getDeviceSettings().phoneConnected && System.getDeviceSettings().connectionAvailable

They can be seperated in order to provide more helpful errors, e.g. "Not connect to your phone", and "Phone connected, no Internet".

Newline character

Hello,

Is it possible to use the new line in a sensor display? if yes, how I should proceed?
I've tried with \n, \n, \r\n but doesn't work. I want to put temperature on 1st line and humidity on 2nd line

      "type": "template",
      "content": "🌡️ {{ states('sensor.0xa4c138a6f9c619b5_temperature') }}°C, 💧 {{ states('sensor.0xa4c138a6f9c619b5_humidity') }}%"

Transmit Battery: Authentication error

I just updated the app on my venu 2 plus and enabled battery reporting. While watcing for the event in the HA developer tools, I didn't see any events appear. It occured to me however that I saw a few authentication errors:

Logger: homeassistant.components.http.ban
Source: components/http/ban.py:129
Integration: HTTP (documentation, issues)
First occurred: 14:37:30 (40 occurrences)
Last logged: 15:23:52

Login attempt or request with invalid authentication from localhost (127.0.0.1). Requested URL: '/api/events/garmin.battery_level'. (Mozilla/5.0 ( compatible ))

The rest of the app works without problems, including toggling of some of my lights and starting two scripts. My HA is exposed through Nabu Casa Cloud (which works without problems for the main functionality of the app, including serving the json-file).

Is there any additional step which needs to be done which might not be documented in https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/BatteryReporting.md ?

Feature request: Confirm dialogue

One feature I'd like to request is a confirmation on entity activation. For example if I have a toggle/tap service that unlocks the door/opens garage door or similar it could be used. The confirm action should require a physical button press. The reason is to not to be able to accidentally trigger such entities by "ghost touches" by for example rain.

Confirm on type "tap" not working

Hello,

Do not know if this is normal or not but adding a confirm on a tap action do not work (at least for me).

   {
      "entity": "cover.portail",
      "name": "Ouvrir Portail",
      "type": "tap",
      "tap_action": {
        "service": "cover.open_cover"
        "confirm": true
      }
    },

Am I missing something ?
This lead to JSON not beeing read (Unavailable).

"Toggle" cannot be an option as entity do not report state an is only usable via a service.

Proposal for a more leaner UI

Hello!

A proposal for a more leaner UI:

  • Remove the texts "menu, on/off, tap etc"
  • Using for "menu" and "tap" although an icon as for "toggle" on the right site of the items name
  • The leaner UI could be an optional choice in the app settings.

Menu icon:

  • Menu icon: The classy "Hamburger Button": ☰
  • Or even more leaner, the "Kebab" one: ⁝

Tap icon:

  • Tap: For example the "White square button": 🔳
  • Or the convention could be: No icon means "tap"

Thanks for your nice work so far :)

Greetings,
someone

Allow parameters to be send with tap menu items

Request from thebogeyman (Marc Schermann) at https://community.home-assistant.io/t/home-assistant-app-for-garmin/637348/107:

Is it somehow possible to add parameters to a script when calling it via the tap_action?
I have something like this:

service: script.send_message
data:
  message: This is a message
  volume: 0.7

This would suggest a JSON format along the lines of:

{
  "$schema": "https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json",
  "title": "Home",
  "items": [
    {
      "entity": "script.configurable_item",
      "name": "Set Volume",
      "type": "tap",
      "tap_action": {
        "service": "script.send_message",
        "data": {
          "message": "This is a message",
          "volume": 0.7
        }
      }
    }
  ]
}

So the changes required are to store the parameters in the local menu item to be included in the makeWebRequest() call. This might be best done as keeping the data part of the JSON object as a Lang.Dictionary Monkey C object in order to include just one additional item into the HTTP call.

Feature Request for open/close covers

Hi,
I just found this project and successfully configured it for my Fenix 7. It is just working fine. Thanks a lot!

I hope it is OK to submit a feature request. I would like to control some covers and it would be great to open or close a cover using my watch. Do you think it is possible to add this?

BR
Michael

.

.

Venu 3 - application doesn't start

Hello,

The application doesn't start in my Venu 3.

I have hime assistant running in docker in my NAS on my lan.

I have set up an https access using let's encrypt.

In my home router I associated the domain used for the certificate to the local ip of the home assistant.

I configured home assistant to expos the rest api.

I created a never expiring access token.

I can access the api url correctly from one pc of the same lan.

--> Bug: in the application on my watch I see :
API: not available
Menu: not available

If I click on it I see the error message :
"No answer, check your internet connection"

Thanks in advance for any advice

Help text for web-based configuration editor

Needs to cover:

  1. Can retrieve menu from URL, but can't publish back. Need to copy & paste. We have a copy button for that.
  2. CTRL+Space to get a list of autocomplete strings
  3. JSON schema vs entity names
  4. Works in templates too, based on text before cursor
  5. In templates, CTRL+Space then CTRL+Space again adds the HA entity name to provide the familiar name
  6. Can render templates locally for testing string format

Any screenshots (sanitised)?

Links to resources:

Reduce startup delay

While I'm on my bike, I'd like to be able to press a few buttons on my watch without looking to open the garage door. However, there is sometimes a several second delay between launching the HomeAssistant app and the menu rendering, and this delay is variable.

I believe this is because the app performs a synchronous HTTP GET to retrieve the configuration.

My configuration is currently stored in Home Assistant's web server, accessed via Nabu Casa. While I suppose I could deploy some edge caching to speed up the Internet part of this operation, this seems less optimal than caching the configuration within the app itself. Of course, with caching comes the cache invalidation problem.

Would you consider some means to allow the user to cache this information to reduce latency?

One idea would be to require the user to explicitly refresh the configuration via an App-provided menu item on the watch. This might be opt-in and enabled only if the user has made a configuration setting through ConnectIQ to disable prefetching.

Another idea would be to add this into the user-provided JSON configuration, such that on subsequent launches, the configuration file is not refreshed automatically, only on-demand.

An extension of this idea would be to add -- in addition to menu item for manual use -- a background, periodic callback to refresh the configuration every N minutes, for some N.

Improved error reporting on non-JSON payloads

When Communications.makeWebRequest(() fails with INVALID_HTTP_BODY_IN_NETWORK_RESPONSE, is there any way to repeat the call to extract any plain text error message for more helpful user feedback?

Impose the requirement for a service field for taps

Now that the JSON schema requires the service field for all "taps", the existence of the service tag needs to be enforced. This was omitted previously due to some notion of allowing a transition period for those devices where scripts executed without the service field. That notion is perhaps flawed, and the change needs to be imposed now.

In HomeAssistantView:

var type    = items[i].get("type")    as Lang.String or Null;
var name    = items[i].get("name")    as Lang.String or Null;
var entity  = items[i].get("entity")  as Lang.String or Null;
var service = items[i].get("service") as Lang.String or Null;
if (type != null && name != null && entity != null) {
    :
                } else if (type.equals("tap") && service != null) {

    :
}

Allow turning off vibration

Is your feature request related to a problem? Please describe.
When making this app available to my partner, she didn't like the vibration caused by executing actions.

Describe the solution you'd like
Add an ability to disable vibrations, either in the app's IQ store configuration or in the dashboard definition

Describe alternatives you've considered
Turn off the vibration globally in the watch, this is not desireable to my partner

Additional context
~~

Tidy up code for tap with no service.

HomeAssistantMenuItem.execScript() (soon to be HomeAssistantService.call() on merge of #9) still tests for no specified service. This is legacy code since the change to enforce a service field be provided in the JSON for every 'tap'.

            if (mService == null) {
                var url = (Properties.getValue("api_url") as Lang.String) + "/services/" + id.substring(0, id.find(".")) + "/" + id.substring(id.find(".")+1, null);
                if (Globals.scDebug) {
                    System.println("HomeAssistantService call() URL=" + url);
                    System.println("HomeAssistantService call() mIdentifier=" + mIdentifier);
                }
                Communications.makeWebRequest(
                    url,
                    null,
                    options,
                    method(:onReturnCall)
                );

The test/clause can now be removed and the code simplified due to recent changes.

Splitting widget and app code

Goals

  1. Having a code base for the app version without "legacy" widget code for achieving space to add new features.
  2. Set the widget version to maintenance only mode (feature freeze, only bug fixing etc.)

Proposal

New repository under "house-of-abbey" for the widget version. For example: "GarminHomeAssistantWidget".

Cloning the current code base into it. Removing all the "legacy" widget related code from the app repo and removing all the glance code in the widget version.

Set the widget repo to "maintenance only mode" by making this clear in the readme.

Nabu casa connection?

I'm getting error code = 0. Assuming it's a nabu casa issue which I know more people are having (again, assumed).

Any inputs for nabu casa users?

Widget?

Hello!

What are the reasons for implementing this as an app?

Plus points for a widget are in my opinion:

  • Can be used while having an active app
  • Will close automatically after some time (while being an app, it has to be close manually (possible battery drain))

Comparison app vs widget can be seen here:
https://developer.garmin.com/connect-iq/connect-iq-basics/app-types/

Have fun,
someone

Add GPS reporting to the background service

User request from https://community.home-assistant.io/t/home-assistant-app-for-garmin/637348/150

would it be possible to report gps coordinates as well?

So the background service would report both battery level, charging state and now GPS too. There could be a dependency on the granularity of the GPS since workout Apps usually take a while to pick up satelites and refine the GPS to a few meters, and the battery is in greater demand at these higher accuracies.

Vivoactive 4S crashes - User reported error

When the API URL is deliberately wrong the application crashes without a helpful error message.

            if (!(WatchUi.getCurrentView()[0] instanceof ErrorView)) {
                // Avoid pushing multiple ErrorViews
                WatchUi.pushView(new ErrorView(strUnhandledHttpErr + responseCode ), new ErrorDelegate(), WatchUi.SLIDE_UP);
            }

The WatchUi.getCurrentView() API call is only available on API Level 3.4.0. In order to maintain support for the current range of devices, the required API level is 3.1.0 hence this call is not available.

A new method to prevent repeat views being pushed is required.

Sensor readings as text display

Hi, would it be possible to display basic sensor data, ex solar panel output from my inverter, or utility power on/off status?

App not showing up in glances on Vivoactive 5

Hello,

I cannot manage to the the application to show up in the glances view on my vivoactive 5. I have checked the add more menu and it does not show up there. However it do show up in apps and recents menu. However if I download the widget version it does show up there. But then I need to have both apps installed. I guess that is not the expected behavior?

I would like to ask about the three problems that have occurred.

{
  "$schema": "https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json",
  "title": "gm_ha",
  "items": [
    {
      "entity": "scene.A/C_off",
      "name": "A/C_off",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.A/C_on",
      "name": "A/C_on",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.Air_clean_off",
      "name": "Air_clean_off",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.Air_clean_on",
      "name": "Air_clean_on",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.ct_light_off",
      "name": "ct_light_off",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.ct_light_on",
      "name": "ct_light_on",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.curtain_off",
      "name": "curtain_off",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.curtain_on",
      "name": "curtain_on",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.Light_lang",
      "name": "Light_lang",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.Light_math_science",
      "name": "Light_math_science",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.Light_Night_mood",
      "name": "Light_Night_mood",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.Light_off",
      "name": "Light_off",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.veranda_off",
      "name": "veranda_off",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
    {
      "entity": "scene.veranda_on",
      "name": "veranda_on",
      "type": "tap",
      "tap_action": {
        "service": "scene.turn_on"
      }
    },
  ]
}

Use Webhooks for reporting battery levels

Docs

https://developers.home-assistant.io/docs/api/native-app-integration/setup
https://developers.home-assistant.io/docs/api/native-app-integration/sensors/

Steps required:

1 Register Webhook

1. Request

POST with token.

https://<homeassistant>/api/mobile_app/registrations
{
  "device_id": <device-id>,
  "app_id": "garmin_home_assistant",
  "app_name": "GarminHomeAssistant",
  "app_version": <app-version>,
  "device_name": <name>,
  "manufacturer": "Garmin",
  "model": <model>,
  "os_name": "ConnectIQ",
  "os_version": "",
  "supports_encryption": false,
  "app_data": {}
}

1. Response

201 (Created)

{
  "cloudhook_url": <ignore>,
  "remote_ui_url": <ignore>,
  "secret": null,
  "webhook_id": "<webhook-id>"
}

2 Register Sensors (2 requests)

2. Request

POST without token.

https://<homeassistant>/api/webhook/<webhook-id>
2. Request[0].body
{
  "type": "register_sensor",
  "data": {
    "device_class": "battery",
    "name": "Battery Level",
    "state": <battery-level>,
    "type": "sensor",
    "unique_id": "battery_level",
    "unit_of_measurement": "%",
    "state_class": "measurement",
    "entity_category": "diagnostic",
    "disabled": false
  }
}
2. Request[1].body
{
  "type": "register_sensor",
  "data": {
    "device_class": "battery_charging",
    "name": "Battery is Charging",
    "state": <battery-is-charging>,
    "type": "binary_sensor",
    "unique_id": "battery_is_charging",
    "entity_category": "diagnostic",
    "disabled": false
  }
}

2. Response

201 (Created)

{
  "success": true
}

3 Update Sensors

Do this continuously.

3. Request

POST without token.

https://<homeassistant>/api/webhook/<webhook-id>
{
  "type": "update_sensor_states",
  "data": [
    {
      "state": <battery-level>,
      "type": "sensor",
      "unique_id": "battery_level"
    },
    {
      "state": <battery-is-charging>,
      "type": "binary_sensor",
      "unique_id": "battery_is_charging"
    }
  ]
}

3. Response

200 (OK)

{
  "battery_level": {
    "success": true
  },
  "battery_is_charging": {
    "success": true
  }
}

Conclusion

In Settings.mc we requests 1 and 2(*2) once and store the resulting webhook id then that can be used to report the battery in the background service using request 3.

This creates its own device in HomeAssistant with its own sensors, so no need for the template sensors as before.

Question: Internal http access not working

Hi,

very nice implementation! I have a question how can I use an internal connection without https. I dont want to make the homeassistant instance accessible from the internet. The clock only needs the internal connection via http. At the moment that does not seem to work. This is true for the api as well as the Menu.json file.
Cheers Jan

Tap or toggle don't work on venu 2

Hello,
First of all, congratulations on your work which is the most accomplished of what I have tested.

I followed the procedure and my watch (Venu2) displays the entities that I configured.

But I cannot send a command, neither "tap" nor "toggle"

I tested my long live token with a rest_command and it 's correct.

Can you help me
Thanks
sorry for my bad english. I am French.

my json config: (ihave changed my entities for security)
{ "$schema": "https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json", "title": "Domicile", "items": [ { "entity": "script.script_ring_desactivation_alarmemaison", "name": "Arret Alarme", "type": "tap" }, { "entity": "switch.tasmota10", "name": "Basc. Porte garage", "type": "toggle" }, { "entity": "switch.tasmota30", "name": "Ambiance1 Salon", "type": "toggle" }, { "entity": "menu.eclairage_salon", "name": "Eclairage Salon", "title": "Salon", "type": "group", "items": [ { "entity": "light.halogenes4", "name": "Halogene", "type": "toggle" }, { "entity": "light.lamp_leds", "name": "Lampe Led", "type": "toggle" }, { "entity": "light.lampe_phones", "name": "Lampe téléphone", "type": "toggle" } ] }, { "entity": "script.script_lampe_couleur_pou_raz", "name": "RAZ Lampe", "type": "tap" }, { "entity": "switch.crnr_tbl_usbs", "name": "Corner Table USBs", "type": "toggle" } ] }

Bug fixes to 2.6

Bug fix release:

  1. Make setting up of webhooks and restarting the background service independent rather than one conditional on the other.
  2. Avoid caching a bad menu.
  3. Beter management of bad JSON in menu definitions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.