Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Location from the Home Zone in hass.config #241

Closed
3 tasks done
askpatrickw opened this issue May 31, 2024 · 14 comments
Closed
3 tasks done

Get Location from the Home Zone in hass.config #241

askpatrickw opened this issue May 31, 2024 · 14 comments
Labels
enhancement New feature or request stale

Comments

@askpatrickw
Copy link

askpatrickw commented May 31, 2024

Describe the feature

This is related to #46 which is a request for a templating integration.

This conversation on the HA Community may be useful.
https://community.home-assistant.io/t/how-does-an-integration-access-has-set-location/734850

Read Location from Home Assistant's Location

This feature is a simpler request which is for the integration to use the Home Zone as the source of the location. This is exposed on the HASS object under hass.config.

On every run, this integration should read the latitude and longitude from hass.config and that would solve the mainline stationary and mobile cases.

This should be the default behavior for new installs.
For existing installs, the existing specified location can be stored as the advanced config.

Advanced Configuration

Location

One might want to use Pirate Weather to see the weather at some other location, in that case the integration can expose manually setting location in advanced configuration which is normally hidden from the user.

Language

Hass.config exposes language and advanced setting could be used an override, or the HASS language could be used instead. The README says only English is supported though, so maybe just remove this and use the HA one if is needed in the future.

Units

Hass.config exposes units. It may be that the HA Units are not specific enough, and you would want and override to enable "SI". I believe UK, CA, US would be covered.

Related: Updating Location using homeassistant.set_location

Mobile uses can use homeassistant.set_location to set the location. Below is an example of using Peplink Mobile Router's GPS (captured from API calls) to do so.

alias: update_peplink_gps
trigger:
  - platform: state
    entity_id: sensor.peplink_gps
action:
  - service: device_tracker.see
    data:
      dev_id: van_luna
      gps:
        - "{{ state_attr('sensor.peplink_gps', 'latitude') }}"
        - "{{ state_attr('sensor.peplink_gps', 'longitude') }}"
  - service: homeassistant.set_location
    data_template:
      latitude: "{{ state_attr('sensor.peplink_gps', 'latitude') }}"
      longitude: "{{ state_attr('sensor.peplink_gps', 'longitude') }}"

Home Assistant version

latest

Integration version

latest

Acknowledgements

  • I have searched this repository and API Repository to see if the feature has already been requested.
  • This featre request is sepecific to the HA Integration.
  • I have written an informative title.
@alexander0042
Copy link
Collaborator

Thanks for asking that question and bringing it to my attention! I was thinking about this a little over the weekend and might have something that could work here. The basic idea is that if someone puts a lat/lon in during setup, use that. Otherwise, the update coordinator could check the location on every update and use that.

The issue here is how to identify the update coordinator to make sure an entity knows what data to read from. This is currently based on location, but there's no real reason we couldn't use the entity name to define it instead. It'll take me a couple weeks to get to this, but adding it to the docket!

@alexander0042 alexander0042 added the keep Issues to keep open label Jun 17, 2024
@askpatrickw
Copy link
Author

I'll add that displaying the location being used on the card would be nice to have too.

image

image

@cloneofghosts
Copy link
Collaborator

When you say location being used do you mean the coordinates of the current location or the name of the current location? Pirate Weather doesn't have a data point for the current location name (you can always request this as a feature in the API repo) but showing the coordinates should be doable.

@askpatrickw
Copy link
Author

I'd live with coordinates, I'm frequently not near a named place anyway.

@cloneofghosts
Copy link
Collaborator

It should be possible to show the location coordinates somewhere but I'll defer to @alexander0042. I also created a feature request for a location name being returned in the API.

@markandersonus
Copy link

Any ETA on this? Dying to get dynamic weather based on location of my RV (I have the pep wave integration)

@askpatrickw
Copy link
Author

People following this Issue should also go put a 👍 on the linked API issue. Pirate-Weather/pirateweather#260

@alexander0042
Copy link
Collaborator

Thanks for tagging that issue- if I can find a way to cache the geonames data, then it's very possible to return a location name.
With respect to the weather card, it's based off the integration name, so I don't know if it would be possible to update it dynamically. Maybe there's another card that might work better for this?

In the meantime, I'm testing a new update that lets the latitude and longitude be left blank during the initial setup, which will then let it pull the data from hass on each update!

alexander0042 added a commit that referenced this issue Aug 15, 2024
- Corrects a small bug about platforms re: Issue #273
- Changes sensor reported times to datetimes re: Issue #275
- Allows for updating locations via hass re: Issue #241
- Allows changing the scan_interval re: Issue #230
@cloneofghosts
Copy link
Collaborator

V1.5.5 has just been released which allows you to enter in 0 as the latitude and longitude to pull in the current location from HA. It doesn't include a location name or output the current coordinates at the moment.

@cloneofghosts cloneofghosts moved this from Todo to In Progress in Pirate Weather Home Assistant Aug 18, 2024
@cloneofghosts cloneofghosts removed the keep Issues to keep open label Aug 18, 2024
@alexander0042
Copy link
Collaborator

Would outputting the current coordinates (as sensors I guess) be helpful here? It'd be easy enough to do, but I'm not sure the value beyond debugging

@cloneofghosts
Copy link
Collaborator

Would outputting the current coordinates (as sensors I guess) be helpful here? It'd be easy enough to do, but I'm not sure the value beyond debugging

I know we used to have debug statements which printed the co-ordinates that it called the API with and I remember we removed it as it was caught by CodeQL.

It could maybe be added back and just ignore the CodeQL warning or if having a sensor would make more sense then it could be setup instead.

@askpatrickw
Copy link
Author

Just as an FYI on the sensor thing...

If you are dynamically updating the location of your HA instance, you must already have some sensor in order to do that.

I'm using a USB GPS Attached to my Victron Cerbo GX which I'm then collecting over MQTT. Other might be using the GPS in their cellular router (like a Peplink) or their Starlink.

Copy link

There has been no activity on this issue in the last ninety days and will automatically close in seven days. Leave a comment on this issue to prevent it from closing automatically.

@github-actions github-actions bot added the stale label Nov 25, 2024
Copy link

github-actions bot commented Dec 2, 2024

This issue has been automatically closed since there has been no further activity after seven days and will be automatically locked in sixty days. Feel free to re-open this issue or you can create a follow-up issue

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Pirate Weather Home Assistant Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
Development

No branches or pull requests

4 participants