custom-components / sensor.avanza_stock

Custom component to get stock data from Avanza for Home Assistant
MIT License
46 stars 10 forks source link

Sort by not working as expected #86

Closed gsolem closed 4 years ago

gsolem commented 4 years ago

Sort by is not sorting as expected. E.g. attached list is set to sort by changePercent- but as you can see it is not working out very well.

Aksje Last Change % Last updated
KID 74.60 4.48 % 8/3/2020, 9:49:39 PM
MOWI 169.95 3.75 % 8/3/2020, 9:59:04 PM
GSF 94.00 2.17 % 8/3/2020, 9:58:57 PM
TOM 381.00 2.06 % 8/3/2020, 9:59:05 PM
ENDUR 1.52 14.72 % 8/3/2020, 9:52:41 PM
VEI 125.60 1.95 % 8/3/2020, 9:50:36 PM
STB 50.02 1.21 % 8/3/2020, 9:58:21 PM
AKER 386.20 0.94 % 8/3/2020, 9:58:48 PM
NEL 18.74 0.40 % 8/3/2020, 9:59:04 PM
ASA 114.00 -1.30 % 8/3/2020, 9:38:34 PM
HEX 46.82 -1.10 % 8/3/2020, 9:55:56 PM
NSKOG 28.00 -0.36 % 8/3/2020, 9:59:12 PM

Above is when using the modify to round to a fixed nos. of decimals, e.g. modify: parseFloat(x).toFixed(2). Without using modify on the column, it is sorting just fine:

Aksje Last Change % Last updated
ENDUR 1.52 14.72 % 8/3/2020, 9:52:41 PM
KID 74.60 4.48 % 8/3/2020, 9:49:39 PM
MOWI 169.95 3.75 % 8/3/2020, 9:59:04 PM
GSF 94.00 2.17 % 8/3/2020, 9:58:57 PM
TOM 381.00 2.06 % 8/3/2020, 9:59:05 PM
VEI 125.60 1.95 % 8/3/2020, 9:50:36 PM
STB 50.02 1.21 % 8/3/2020, 9:58:21 PM
AKER 386.20 0.94 % 8/3/2020, 9:58:48 PM
NEL 18.74 0.4 % 8/3/2020, 9:59:04 PM
NSKOG 28.00 -0.36 % 8/3/2020, 9:59:12 PM
HEX 46.82 -1.1 % 8/3/2020, 9:55:56 PM
ASA 114.00 -1.3 % 8/3/2020, 9:38:34 PM
claha commented 4 years ago

Your Change % column seems to be a string, so given that it is sorted correctly. There is no functionality in this component to sort lists so I'm not sure how I can help you. The changePercent attribute of an avanza_stock sensor is a float so you must be doing something with the data. Please provide more info, configuration etc. if you need further help.

gsolem commented 4 years ago

@claha You are right, actually I believe this is related to the flex-table component in home assistant and not the Avanza sensor. Sorry for the confusion, I will follow up under the table card component.