AlexandrErohin / home-assistant-flightradar24

Flightradar24 integration for Home Assistant
https://community.home-assistant.io/t/custom-component-flightradar24
MIT License
137 stars 15 forks source link

Maybe also include squawk? #8

Closed sj3fk3 closed 9 months ago

sj3fk3 commented 9 months ago

Very nice work on this integration! I previously made a pyscript app to pull from opensky, but was looking into doing the same for flightradar24 when I came across this! Very nicely done! One thing I'm missing is squawk, usually I don't care about it that much, but I do like to look out for squawk 7700/7600 and 7500 (we had one a while ago at EHAM, that turned out to be pilot error).

AlexandrErohin commented 9 months ago

Ok, Ill add this in the future release

AlexandrErohin commented 9 months ago

@sj3fk3 added squawk

sj3fk3 commented 9 months ago

I think you need a subscription plan to get squawk out of the API, so without authentication this is not going to work :-(

https://www.flightradar24.com/premium

I do have a subscription, so if you ever consider also including authentication I can test.

AlexandrErohin commented 9 months ago

@sj3fk3 Ok. I will add it in the future releases, after I add options changing. I dont think it should be in the setup window. It would be in the edit configuration window as additional setting. What do you think?

sj3fk3 commented 9 months ago

@sj3fk3 Ok. I will add it in the future releases, after I add options changing. I dont think it should be in the setup window. It would be in the edit configuration window as additional setting. What do you think?

I agree, also because most users won't use it anyway, should not be part of the happy flow if you ask me.

AlexandrErohin commented 8 months ago

@sj3fk3 Hi. I have added authentication, could you download v1.1.0 and try? I dont have subscription, so would be great if you could test it

sj3fk3 commented 8 months ago

I'm afraid it does not work, anyway I can reach you pvt? Don't mind sharing log-in for a while so you can debug.

AlexandrErohin commented 8 months ago

Authentication doesnt work? or squawk is None ?

sj3fk3 commented 8 months ago

After setup, I go to config and add usr/psw it then shows this:

Screenshot 2024-01-17 at 12 15 57
AlexandrErohin commented 8 months ago

Is there any logs in Settings->System->Logs ?

sj3fk3 commented 8 months ago

ah, the authentication is send in a blocking call? 2024-01-17 13:09:23.649 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to putrequest inside the event loop by custom integration 'flightradar24' at custom_components/flightradar24/__init__.py, line 31: client = FlightRadar24API(username, password) if username and password else FlightRadar24API(), please create a bug report at https://github.com/AlexandrErohin/home-assistant-flightradar24/issues 2024-01-17 13:09:23.649 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry FlightRadar24 for flightradar24 Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 406, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/flightradar24/__init__.py", line 31, in async_setup_entry client = FlightRadar24API(username, password) if username and password else FlightRadar24API() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/FlightRadar24/api.py", line 51, in __init__ self.login(user, password) File "/usr/local/lib/python3.11/site-packages/FlightRadar24/api.py", line 348, in login response = APIRequest(Core.user_login_url, headers = Core.json_headers, data = data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/FlightRadar24/request.py", line 56, in __init__ self.__response = request_method(url, headers = headers, cookies = cookies, data = data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 115, in post return request("post", url, data=data, json=json, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen httplib_response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 416, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 244, in request super(HTTPConnection, self).request(method, url, body=body, headers=headers) File "/usr/local/lib/python3.11/http/client.py", line 1286, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.11/http/client.py", line 1297, in _send_request self.putrequest(method, url, **skips) File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 219, in putrequest return _HTTPConnection.putrequest(self, method, url, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/async_.py", line 169, in protected_loop_func check_loop(func, strict=strict) File "/usr/src/homeassistant/homeassistant/util/async_.py", line 156, in check_loop raise RuntimeError( RuntimeError: Blocking calls must be done in the executor or a separate thread; Useawait hass.async_add_executor_job(); at custom_components/flightradar24/__init__.py, line 31: client = FlightRadar24API(username, password) if username and password else FlightRadar24API()

AlexandrErohin commented 8 months ago

I have fixed it - Please try v1.1.1

sj3fk3 commented 8 months ago

Works like a charm! Including squawk in the attributes! <3

AlexandrErohin commented 8 months ago

Great. Would be great to know which fields allowed for subscription only

sj3fk3 commented 8 months ago

https://www.flightradar24.com/premium

AlexandrErohin commented 8 months ago

@sj3fk3 Thanks