MaxWinterstein / homeassistant-addons

GNU General Public License v3.0
137 stars 39 forks source link

[adsb-multi-portal-feeder] Add Aircraft sensors #172

Open MaxWinterstein opened 1 year ago

MaxWinterstein commented 1 year ago

Created to continue the discussion that is slightly lost here: https://github.com/MaxWinterstein/homeassistant-addons/commit/5be38c6d740f4645bb49719c5497db1b6d72f36c

@plo53 It looks good, will try to get it integrated and tested! :)

MaxWinterstein commented 1 year ago

@plo53 first quick feedback - it works! ❤️

Currently drafting the release, maybe get it done before the toddler ends his nap 🤞

a) Can you add some uuid to the sensor? Maybe someone want's to e.g. overwrite the icon or stuff image

b) In the mood to add sensors to the other feeders as well? 😉

MaxWinterstein commented 1 year ago

Can be tested with just released version 1.27.0 🥳

plo53 commented 1 year ago

this sensor did have a unique id

sensor_ids

plo53 commented 1 year ago

b) Why not. Need first to register feeding to them, and see what can be done depending on openness of their implementation

plo53 commented 1 year ago

Just installed 1.27.0 Everything working fine

Didn't reproduce any unique_id missing issue

plo53 commented 1 year ago

About additional sensors for other feeders:

plo53 commented 1 year ago

Good news:

plo53 commented 1 year ago

New sensors for Opensky and Planefinder in release hassio-sensors v1.1.0

MaxWinterstein commented 1 year ago

Awesome ❤️

Updated along #174

yousaf465 commented 1 year ago

@plo53 if you could add a max range sensor too?

plo53 commented 1 year ago

In local feeders, I may have (or not at all) limited history of aircraft postions.

So depends by what do you mean by max range.

For adsbexchange and adsb.fi, I can retrieved the outlines. From them I can compute the max distance from the receiver location.

For opensky and planefinder, I have at least the aircraft positions, I can compute the farthest over time.

yousaf465 commented 1 year ago

for example flight radar gives it as max range

image

so max range will give us an idea about our antenna placement etc etc over time.

plo53 commented 1 year ago

yes indeed, this is the max range for one day history

I prototyped a sensor to track the "farthest" aircraft over time:

2023-07-12 17_47_51-History – Home Assistant

Then using a Statistics Graph card like bellow, we should get the same Max Range per day as FR24:

2023-07-12 18_04_59-Overview – Home Assistant

Let us wait for some days to see ...

yousaf465 commented 1 year ago

yes indeed, this is the max range for one day history

I prototyped a sensor to track the "farthest" aircraft over time:

2023-07-12 17_47_51-History – Home Assistant

Then using a Statistics Graph card like bellow, we should get the same Max Range per day as FR24:

2023-07-12 18_04_59-Overview – Home Assistant

Let us wait for some days to see ...

yes wanted this sensor, we can use it for any graph, per hour, per day or per week etc.

I am using this custom history graph, which creates bar graph on it's own

https://github.com/alexarch21/history-explorer-card

plo53 commented 1 year ago

Which feeder are you using ?

PS: Alex's History explorer card is awesome !

yousaf465 commented 1 year ago

Which feeder are you using ?

PS: Alex's History explorer card is awesome !

All feeders all mentioned in this screenshot and radarbox.

image

plo53 commented 1 year ago

You may add adsb.fi , launched by some adsbexchange main developpers fired or leave after sold out

yousaf465 commented 1 year ago

You may add adsb.fi , launched by some adsbexchange main developpers fired or leave after sold out

it is already added. image

plo53 commented 1 year ago

hassio-sensors v1.1.2-1 released, to be reviewed by Max

MaxWinterstein commented 1 year ago

Update released - works fine. Thanks @plo53 !

Would it be possible to add the sensors to the Home Assistand Addon? Not sure how that via supervisor works, only know it from mqtt site. Rel https://github.com/MaxWinterstein/toogoodtogo-ha-mqtt-bridge/issues/21

So the sensors will be listed at the addon page?

image

yousaf465 commented 1 year ago

Update released - works fine. Thanks @plo53 !

Would it be possible to add the sensors to the Home Assistand Addon? Not sure how that via supervisor works, only know it from mqtt site. Rel MaxWinterstein/toogoodtogo-ha-mqtt-bridge#21

So the sensors will be listed at the addon page?

image

that will simplify it a lot. just click Add to Dashboard and you are done. instead of finding each and every sensor.

plo53 commented 1 year ago

Yeah sure. Need to figure out how to integrate the sensors list in the addon page

@MaxWinterstein : can you explain how you integrated your sensors into the device ?

plo53 commented 1 year ago

I presume the sensor list in the device is a predifined list by HA, that needs to be handle by the addon.

Here ie the version is not found:

2023-07-17 11_27_49-Settings – Home Assistant

yousaf465 commented 1 year ago

https://developers.home-assistant.io/docs/creating_component_index/

does this point to in any right direction?

plo53 commented 1 year ago

Yes this is right direction. This is developping a custom integration defining a device and its sensors logic.

This is outside of the addon itself.

MaxWinterstein commented 1 year ago

Wouldn't it be possible to just add device info to the payload, so it will be created and all sensors will be assigned to this device?

plo53 commented 1 year ago

The hassio REST API doesn't provide any device settings method.

The "ideal" solution would be an associated custom integration, but I am not in favor because then your add-on would no longer be independent.

I will investigate if replacing REST API communication by MQTT can provide much device control

MaxWinterstein commented 1 year ago

At least device autodiscovery would work in that case 🤔

Btw, I saw this error while fiddling around:

Traceback (most recent call last):
  File "/usr/local/share/planefinder/planefinder_max-range.py", line 28, in <module>
    ulat=radians(float( options['MLAT_EXACT_LAT'] ))
ValueError: could not convert string to float: 'HOMEASSISTANT_LATITUDE'

I named this a 'magic variable', as it will be replaced by some script:

https://github.com/MaxWinterstein/homeassistant-addons/blob/052e8c35f89071e9c056f504b657dc7b07a4ca09/adsb-multi-portal-feeder/export-env-from-config.sh#L24

No deeper search here as just on coffee break, but i guess sourcing my bash script on top of the sensors might do the job: https://github.com/MaxWinterstein/homeassistant-addons/blob/main/adsb-multi-portal-feeder/Dockerfile#L25

plo53 commented 1 year ago

In fact my script is directly reading /data/options.json and I am expecting exact lat/lon float values configured in the addon

MaxWinterstein commented 1 year ago

If you want, I can inject this via my dockerfile, just like the others.

plo53 commented 1 year ago

Initialy I selected to use EXACT_LAT/LON (MLAT) to enable more precise range computing, guessing the site HOMEASSISTANT_LAT/LON may be more approximative. Anyway, I can update my script to retrieve the values from your env variables. At the moment, to get rid of the traceback, define EXACT_LAT/LON in the addon config.

plo53 commented 1 year ago

PS: I noted it in the Readme. But your are right, especially for feeder that doesn't enable MLAT, this can trouble users.

2023-07-18 10_43_41-plo53_adsb-hassio-sensors_ Home assistant _ Aircraft sensors for MaxWinterstein_

plo53 commented 1 year ago

SURVEY : I have implemented in my local dev version a one day tracking of aircrafts seen by my receiver. Let me know if it brings interest ? Home Assistant ADS-B Aircraft Tracked

plo53 commented 1 year ago

Would it be possible to add the sensors to the Home Assistand Addon? Not sure how that via supervisor works, only know it from mqtt site. Rel MaxWinterstein/toogoodtogo-ha-mqtt-bridge#21 So the sensors will be listed at the addon page? that will simplify it a lot. just click Add to Dashboard and you are done. instead of finding each and every sensor.

I am progressing reworking the adsb sensors from hassio to mqtt with device discovery.

adsb-mqtt

adsb-mqtt-sensors

Question : how to manage backward compatibility ?