Skip to content

Commit

Permalink
feat: update sensor properties, update documentation with examples (#11)
Browse files Browse the repository at this point in the history
* feat: update sensor properties, update documentation with examples

* fix: revert hacs.json change
  • Loading branch information
stijnpiron authored Dec 24, 2024
1 parent 5f33818 commit e83ccc2
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 5 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ Provides realtime overview of available parking spots in the Ghent parking lots
### Installations via HACS
[![hacs_badge](https://img.shields.io/badge/HACS-Custom-41BDF5.svg)](https://github.com/hacs/integration)

[![Open your Home Assistant instance and open this repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=stijnpiron&repository=parking_gent)

The integration is not yet added in HACS, so a custom repository must be added to get it to work: `stijnpiron/parking_gent`

[//]: # (- In HACS, look for "parking gent" and install and restart)
[//]: # ( - If the integration was not found, please add custom repository `stijnpiron/parking_gent` as integration)
- add the config to the `configuration.yaml` file:

```
sensor:
- platform: parking_gent
```

## Examples
- [Plotting the sensors on a map](documentation/custom_map-card.md)
- [Navigating via a script to the selected parking](documentation/navigate_to_parking.md)
2 changes: 1 addition & 1 deletion custom_components/parking_gent/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/stijnpiron/parking_gent/issues/",
"requirements": [],
"version": "1.0.2"
"version": "1.1.0"
}
4 changes: 4 additions & 0 deletions custom_components/parking_gent/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def device_state_attributes(self):
"isOpenNow": bool(self.parking_data["isOpenNow"]),
"lastUpdate": self.parking_data["lastUpdate"],
"location": self.parking_data["location"],
"latitude": self.parking_data["location"]["lat"],
"longitude": self.parking_data["location"]["lon"],
"occupation": self.parking_data["occupation"],
"openingTimes": self.parking_data["openingTimes"],
"totalCapacity": self.parking_data["totalCapacity"],
Expand All @@ -157,6 +159,8 @@ def extra_state_attributes(self):
"isOpenNow": bool(self.parking_data["isOpenNow"]),
"lastUpdate": self.parking_data["lastUpdate"],
"location": self.parking_data["location"],
"latitude": self.parking_data["location"]["lat"],
"longitude": self.parking_data["location"]["lon"],
"occupation": self.parking_data["occupation"],
"openingTimes": self.parking_data["openingTimes"],
"totalCapacity": self.parking_data["totalCapacity"],
Expand Down
21 changes: 21 additions & 0 deletions documentation/custom_map-card.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Show entities on a map
The integration returns a list of sensors, which can be plotted out on a map:
![entities on a map](custom_map-card.png)

When using the [`custom:map-card`](https://github.com/nathan-gs/ha-map-card) integration, it is possible to add tap actions to the plotted sensors, which then can trigger a navigation event.

Example map-card configuration, with only one sensor for readability:
```yaml
type: custom:map-card
card_size: 8
entities:
- entity: sensor.savaanstraat
display: state
tap_action:
action: call-service
service: script.navigate_to_location
data:
entity_id: sensor.savaanstraat
```
This calls a service [`script.navigate_to_location`](navigate_to_parking.md) which then triggers a Waze url that makes Waze start navigating towards the selected parking.
Binary file added documentation/custom_map-card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions documentation/navigate_to_parking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Navigate to parking script
When setting a tap_action on the map-card component, this is an example of a script that will show a notification on your mobile device.\
When the notification is tapped, it will launch Waze (must be installed) and start navigating to the selected parking.

```yaml
alias: Navigate to Location
description: Start Waze navigation to a specific location directly
fields:
entity_id:
selector:
entity: {}
name: Entity ID
sequence:
- variables:
latitude: "{{ state_attr(entity_id, 'latitude') }}"
longitude: "{{ state_attr(entity_id, 'longitude') }}"
location: "{{ state_attr(entity_id, 'friendly_name') }}"
- data:
message: "Navigate to: {{ location }}"
data:
url: |
waze://?ll={{ latitude | float }},{{ longitude | float }}&navigate=yes
action: notify.notify
```
Other navigation applications are also possible, just need to replace the url with the appropriate one for the other navigation application.

0 comments on commit e83ccc2

Please sign in to comment.