fratsloos / fr24_card

Lovelace card for showing Dump1090 data from FR24 in Home Assistant
42 stars 5 forks source link

e is undefined #16

Closed fribse closed 2 years ago

fribse commented 2 years ago

Describe the bug The frontend sometimes shows billede

To Reproduce Steps to reproduce the behavior:

  1. Simply add the card to a tab
  2. Set up the card with a few standard settings

Expected behavior Sometimes it works as expected, and shows the list of planes, other times it just shows that odd message

Screenshots Firefox billede Chrome billede

Environment (please complete the following information):

Additional context FR24: Linux/generic/static_armel/1.0.29-10 Raspberry Pi 3b+

Configuration

type: custom:fr24-card
entity: sensor.fr24_aircraft
title: Fly over os
units_in_table: true
units: metric
larger_units: true

If possible, also supply the JSON of aircraft.json.


{ "now" : 1661157367.0,
  "messages" : 266121,
  "aircraft" : [
    {"hex":"4ca66f","squawk":"6513","altitude":5625,"vert_rate":1984,"track":151,"speed":312,"mlat":[],"tisb":[],"messages":17,"seen":49.9,"rssi":-34.1},
    {"hex":"4aca50","squawk":"3755","flight":"NOZ3QJ  ","lat":55.662140,"lon":12.952714,"nucp":7,"seen_pos":0.1,"altitude":36000,"vert_rate":0,"track":346,"speed":486,"category":"A3","mlat":[],"tisb":[],"messages":1441,"seen":0.1,"rssi":-28.7},
    {"hex":"471f7e","mlat":[],"tisb":[],"messages":2,"seen":142.8,"rssi":-41.5},
    {"hex":"45cab6","mlat":[],"tisb":[],"messages":29,"seen":194.1,"rssi":-34.6},
    {"hex":"3c66e2","squawk":"6454","flight":"DLH7AE  ","lat":55.941696,"lon":13.009560,"nucp":7,"seen_pos":2.9,"altitude":36975,"vert_rate":0,"track":357,"speed":464,"category":"A3","mlat":[],"tisb":[],"messages":2774,"seen":0.1,"rssi":-33.3},
    {"hex":"501d20","mlat":[],"tisb":[],"messages":5,"seen":201.9,"rssi":-37.5},
    {"hex":"471f80","mlat":[],"tisb":[],"messages":134,"seen":165.0,"rssi":-35.5},
    {"hex":"4596c1","squawk":"7000","altitude":1175,"mlat":[],"tisb":[],"messages":42,"seen":9.4,"rssi":-34.5},
    {"hex":"345084","squawk":"0751","flight":"VLG1507 ","lat":55.133194,"lon":12.168005,"nucp":7,"seen_pos":22.0,"altitude":22750,"vert_rate":1984,"track":220,"speed":374,"mlat":[],"tisb":[],"messages":369,"seen":10.7,"rssi":-34.5}
  ]
}
fratsloos commented 2 years ago

Thanks for the feedback @fribse. Is the supplied JSON from the moment when you get the error message? If not, is it possible to get the JSON from that exact moment?

fribse commented 2 years ago

Hmm, I'm trying to 'catch' it, it mostly happens first time I load Home Assistant lovelace, so then if I press refresh, it shows it (normally), and it's difficult to catch it from dump1090 fast enough :-)

fratsloos commented 2 years ago

When you say the first time when you load it, do you mean the first time after restarting Home Assistant, or the first time after you restarted your browser?

fribse commented 2 years ago

First time I load the browser. A few times I've had to do a CTRL+F5 to make it go away, otherwise a simple F5 will clear up the problem.

fratsloos commented 2 years ago

I can't reproduce the error. It seems like the entity is not loaded the first time you open the page, which is something on your environment. I've added a check on the data from then entity, which throws an error when rendering the table and when there is no data. This fixes the error that you got, but not the cause of it. I don't think I'm able to fix that.

Released in v0.5.2.

fribse commented 2 years ago

Not sure if I caught it this time @fratsloos ?

{ "now" : 1661801970.9,
  "messages" : 709610,
  "aircraft" : [
    {"hex":"3c5427","squawk":"7037","flight":"BCS3317 ","lat":55.686951,"lon":12.304173,"nucp":7,"seen_pos":5.7,"altitude":6025,"vert_rate":-1280,"track":190,"speed":280,"category":"A5","mlat":[],"tisb":[],"messages":167,"seen":4.7,"rssi":-31.6},
    {"hex":"4aca6b","squawk":"2504","flight":"SAS1221 ","lat":55.855470,"lon":12.422276,"nucp":7,"seen_pos":9.3,"altitude":10925,"vert_rate":1280,"track":302,"speed":341,"category":"A3","mlat":[],"tisb":[],"messages":306,"seen":7.2,"rssi":-34.0},
    {"hex":"4aca6d","mlat":[],"tisb":[],"messages":793,"seen":245.3,"rssi":-34.0},
    {"hex":"4520ea","mlat":[],"tisb":[],"messages":1325,"seen":265.3,"rssi":-34.2}
  ]
}
fratsloos commented 2 years ago

I'm sorry, I can't reproduce your error. I've used your json but no luck. I see the two planes in the output. Did you update to 0.5.2 and still have the issue?

fribse commented 2 years ago

This morning I see this: billede But going to the fr24 I see this:

{ "now" : 1662528197.2,
  "messages" : 28051,
  "aircraft" : [
    {"hex":"48415f","squawk":"7675","altitude":38000,"vert_rate":64,"track":232,"speed":427,"mlat":[],"tisb":[],"messages":229,"seen":0.5,"rssi":-33.9},
    {"hex":"440052","mlat":[],"tisb":[],"messages":56,"seen":223.1,"rssi":-35.1},
    {"hex":"406b62","mlat":[],"tisb":[],"messages":476,"seen":119.9,"rssi":-33.1}
  ]
}
fribse commented 2 years ago

Today I got this: billede Taken from dump1090


{ "now" : 1662794567.9,
  "messages" : 120377,
  "aircraft" : [
    {"hex":"5110e9","mlat":[],"tisb":[],"messages":3023,"seen":134.0,"rssi":-33.7},
    {"hex":"48ae20","mlat":[],"tisb":[],"messages":448,"seen":292.3,"rssi":-34.4}
  ]
}
fratsloos commented 2 years ago

@fribse In your JSON there is no valid data. Both tracked flights are missing data to show on the card. That's why you got the initial error, and after the update the new error.

I think I should implement something (like a warning) for the situation when there are no tracked flights, instead of throwing the exception (current).

fribse commented 2 years ago

Well, it's all up to you of course, I just report what I see, but I'm glad I finally got a result showing the right data :-) I think you should just show 'no flights' or something like that, as soon as there is traffic again, it shows it correctly again.

fratsloos commented 2 years ago

It took a while, but I made an adjustment to the card when no planes were found. This adjustment can be found in the pre-release I just released.

You can download the pre-release via HACS, by choosing 'Show beta versions' in the redownload option of the card and then installing version 0.6.0-alpha. Note: This update uses the new version of browser_mod. That must be installed first, unless you don't use popups in the card.

Screenshot 2022-10-15 at 13 34 16

BrettEBowman commented 2 years ago

My flight tracker at my other house is currently powered off. With this beta version, the FR24 card is now showing "No aircrafts detected!" rather than the old error. However, in my current situation it is really a little different since the entire REST call should be failing rather than the call succeeding but not have any flight data.

I'm not sure if you can do this or not, but it would be nice if you could have 2 different error messages. The current new one is great for that "normal" situation of the tracker being up and running, but no flights within range. But if the REST call isn't successful, I'd prefer to see some sort of a "error" message indicating that the server call was unsuccessful. Looking at the HA sensor, it seems like the REST interface is giving it a Status of "OK" in both situations. But when the server isn't up, the only attribute displayed is the "Friendly Name".

fratsloos commented 2 years ago

In the last commit, a modification was made to give a proper error if there is no data, as suggested by @BrettEBowman.

Screenshot 2022-10-17 at 20 45 22

These changes will be available through a pre-release later this week, after some more testing on my side.

BrettEBowman commented 2 years ago

Looks great. Thanks!

fratsloos commented 2 years ago

I've just released version v0.6.0-beta which is available in HACS beta versions with the latest changes.

fratsloos commented 2 years ago

Fixed in v0.6.0.