Giter Site home page Giter Site logo

Comments (2)

philipabbey avatar philipabbey commented on September 12, 2024

Looking trivial to extract from the watch:

var myLocation = Position.getInfo().position.toDegrees();
System.println("Position, lat:  " + myLocation[0] + " long: " + myLocation[1]);

@JosephAbbey What's the best way to include this in the API call?

            Communications.makeWebRequest(
                (Properties.getValue("api_url") as Lang.String) + "/webhook/" + (Properties.getValue("webhook_id") as Lang.String),
                {
                    "type" => "update_sensor_states",
                    "data" => [
                        {
                            "state"     => System.getSystemStats().battery,
                            "type"      => "sensor",
                            "unique_id" => "battery_level"
                        },
                        {
                            "state"     => System.getSystemStats().charging,
                            "type"      => "binary_sensor",
                            "unique_id" => "battery_is_charging"
                        }
                    ]
                },
                {
                    :method       => Communications.HTTP_REQUEST_METHOD_POST,
                    :headers      => {
                        "Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON
                    },
                    :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
                },
                method(:onReturnBatteryUpdate)
            );

I can then test on a real device.

from garminhomeassistant.

JosephAbbey avatar JosephAbbey commented on September 12, 2024

You would also need to amend the WebhookManager setup to include it as a sensor.

Although, the official way is to use a separate request, as seen here, this creates an actual device tracker in homeassistant, rather than a sensor.

I currently have a version that includes the current activity type on my local branch which uses the original request.

from garminhomeassistant.

Related Issues (20)

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.