Allow to fetch location via API

This commit is contained in:
Max Winterstein
2022-03-29 23:34:54 +02:00
parent 296fc72dcf
commit 646de6abad
5 changed files with 36 additions and 12 deletions

View File

@@ -1,5 +1,10 @@
# Changelog # Changelog
## [1.0.3] - 2021-03-29
- Introduce magic variables (`HOMEASSISTANT_LATITUDE`, `HOMEASSISTANT_LONGITUDE`, `HOMEASSISTANT_ELEVATION`)
- Optimize config schema
## [1.0.2] - 2021-03-29 ## [1.0.2] - 2021-03-29
- Fix typ0 in config template, should be `MLAT_EXACT_LON` instead `MLAT_EXACT_LONG`. - Fix typ0 in config template, should be `MLAT_EXACT_LON` instead `MLAT_EXACT_LONG`.

View File

@@ -28,4 +28,7 @@ RUN mkdir -p /etc/s6-overlay/s6-rc.d/banner && \
touch /etc/s6-overlay/s6-rc.d/user/contents.d/banner && \ touch /etc/s6-overlay/s6-rc.d/user/contents.d/banner && \
mv /etc/s6-overlay/s6-rc.d/banner/00-banner.sh /etc/s6-overlay/s6-rc.d/banner/script && \ mv /etc/s6-overlay/s6-rc.d/banner/00-banner.sh /etc/s6-overlay/s6-rc.d/banner/script && \
chmod +x /etc/s6-overlay/s6-rc.d/banner/script && \ chmod +x /etc/s6-overlay/s6-rc.d/banner/script && \
sed -i '1 s/^.*$/#!\/command\/with-contenv bashio/' /etc/s6-overlay/s6-rc.d/banner/script sed -i '1 s/^.*$/#!\/command\/with-contenv bashio/' /etc/s6-overlay/s6-rc.d/banner/script
# enhance timeout, as sometimes the api calls are slow (rate limited?)
ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=30000

View File

@@ -40,6 +40,12 @@ See [docker-fr24feed-piaware-dump1090](https://github.com/Thom-x/docker-fr24feed
I pre-provivde the (i guess) most used workflow: Send data from USB ADB-S stick to FlightRadar24, FlightAware, ADSBexchange and Plane Finder and have a nice little web based overview as Home Assistant menu entry. I pre-provivde the (i guess) most used workflow: Send data from USB ADB-S stick to FlightRadar24, FlightAware, ADSBexchange and Plane Finder and have a nice little web based overview as Home Assistant menu entry.
It it possible to retrive and use the location information of home assistant itself, using some magic variables, which will be replaced automatically:
- `HOMEASSISTANT_LATITUDE`
- `HOMEASSISTANT_LONGITUDE`
- `HOMEASSISTANT_ELEVATION`
If you want to add anything else just add the corresponding environment variable as config option. If you want to add anything else just add the corresponding environment variable as config option.
You might need to press the three little dots in the upper right corner and choose `Edit in YAML`. You might need to press the three little dots in the upper right corner and choose `Edit in YAML`.

View File

@@ -2,7 +2,7 @@ slug: adsb-multi-portal-feeder
stage: experimental stage: experimental
url: https://github.com/MaxWinterstein/homeassistant-addons/ url: https://github.com/MaxWinterstein/homeassistant-addons/
usb: true usb: true
version: 1.0.2 version: 1.0.3
arch: arch:
- armhf - armhf
- armv7 - armv7
@@ -10,7 +10,8 @@ arch:
- amd64 - amd64
boot: auto boot: auto
description: Dump1090 based feeder for FlightRadar24, FlightAware and more description: Dump1090 based feeder for FlightRadar24, FlightAware and more
hassio_api: false hassio_api: true
homeassistant_api: true
ingress: true ingress: true
ingress_port: 8080 ingress_port: 8080
init: false init: false
@@ -27,8 +28,8 @@ options:
ADSBEXCHANGE_UUID: "" ADSBEXCHANGE_UUID: ""
PLANEFINDER_SHARECODE: "" PLANEFINDER_SHARECODE: ""
HTML_SITE_LAT: 50.033056 HTML_SITE_LAT: HOMEASSISTANT_LATITUDE
HTML_SITE_LON: 8.570556 HTML_SITE_LON: HOMEASSISTANT_LONGITUDE
panel_icon: mdi:airplane panel_icon: mdi:airplane
panel_title: ADS-B Feeder panel_title: ADS-B Feeder
@@ -80,19 +81,19 @@ schema:
# ADS-B Exchange # ADS-B Exchange
ADSBEXCHANGE_UUID: str? ADSBEXCHANGE_UUID: str?
ADSBEXCHANGE_STATION_NAME: str? ADSBEXCHANGE_STATION_NAME: str?
ADSBEXCHANGE_MLAT: str? ADSBEXCHANGE_MLAT: bool?
# Exact coordinates for MLAT # Exact coordinates for MLAT
MLAT_EXACT_LAT: float? MLAT_EXACT_LAT: match([+-]?(([1-9][0-9]*)|(0))([.,][0-9]+)?|HOMEASSISTANT_LATITUDE)?
MLAT_EXACT_LON: float? MLAT_EXACT_LON: match([+-]?(([1-9][0-9]*)|(0))([.,][0-9]+)?|HOMEASSISTANT_LONGITUDE)?
MLAT_ALTITUDE_MSL_METERS: int? MLAT_ALTITUDE_MSL_METERS: match([+-]?(([1-9][0-9]*)|(0))([.,][0-9]+)?|HOMEASSISTANT_ELEVATION)?
# Plane Finder # Plane Finder
PLANEFINDER_SHARECODE: str? PLANEFINDER_SHARECODE: str?
# Dump1090 & Web UI # Dump1090 & Web UI
HTML_SITE_LAT: float? HTML_SITE_LAT: match([+-]?(([1-9][0-9]*)|(0))([.,][0-9]+)?|HOMEASSISTANT_LATITUDE)?
HTML_SITE_LON: float? HTML_SITE_LON: match([+-]?(([1-9][0-9]*)|(0))([.,][0-9]+)?|HOMEASSISTANT_LONGITUDE)?
HTML_SITE_NAME: str? HTML_SITE_NAME: str?
HTML_DEFAULT_TRACKER: list(FlightAware|Flightradar24)? HTML_DEFAULT_TRACKER: list(FlightAware|Flightradar24)?
HTML_RECEIVER_STATS_PAGE_FLIGHTAWARE: url? HTML_RECEIVER_STATS_PAGE_FLIGHTAWARE: url?

View File

@@ -5,7 +5,10 @@
# #
# This needs to be sourced ($ source $0) # This needs to be sourced ($ source $0)
CONFIG=$(curl -s -H "Authorization: Bearer ${SUPERVISOR_TOKEN}" -H "Content-Type: application/json" http://supervisor/core/api/config)
LAT=$(echo $CONFIG | jq '.latitude')
LON=$(echo $CONFIG | jq '.longitude')
ELE=$(echo $CONFIG | jq '.elevation')
# TODO: Find a way to use bashio and source together # TODO: Find a way to use bashio and source together
@@ -18,6 +21,12 @@ fi
# thx https://stackoverflow.com/a/48513046/635876 # thx https://stackoverflow.com/a/48513046/635876
while read -rd $'' line while read -rd $'' line
do do
if [[ $line == *"HOMEASSISTANT_LATITUDE" ]] || [[ $line == *"HOMEASSISTANT_LONGITUDE" ]] || [[ $line == *"HOMEASSISTANT_ELEVATION" ]]; then
line=$(echo $line | sed "s/HOMEASSISTANT_LATITUDE/$LAT/")
line=$(echo $line | sed "s/HOMEASSISTANT_LONGITUDE/$LON/")
line=$(echo $line | sed "s/HOMEASSISTANT_ELEVATION/$ELE/")
fi
# echo $line
export "$line" export "$line"
done < <(jq -r <<<"$(cat /data/options.json)" \ done < <(jq -r <<<"$(cat /data/options.json)" \
'to_entries|map("\(.key)=\(.value)\u0000")[]') 'to_entries|map("\(.key)=\(.value)\u0000")[]')