iprak / yahoofinance

Home Assistant component which allows you to get stock updates from Yahoo finance.
MIT License
81 stars 11 forks source link

Trending argument not honored? #134

Closed oliv3r closed 5 months ago

oliv3r commented 5 months ago

Having just installed yahoo finance, and using the sensor also in my gnome-desktop, I was a bit 'annoyed' by the fact it was print 'EUR' instead of €, which saves some space. Going over the documentation, I found that I could even replace it with the trending status, which was even more useful. I can 'imagine' € :p

So I copy pasted some config values:

show_trending_icon: true
scan_interval:
  hours: 6
include_fifty_day_values: false
include_post_values: false
include_pre_values: false
symbols:
  - xxx
  - yyy
  - zzz

Did I typo paste something?

iprak commented 5 months ago

show_trending_icon is working as described. Trending icons (trending-up, trending-down or trending-neutral) can be displayed instead of currency based icon by specifying show_trending_icon. Theunit_of_measurement` is still USD and that is what HomeAssistant displays. I can introduce an optional setting to use currency_symbol instead of currency.

oliv3r commented 5 months ago

show_trending_icon is working as described.

But what am I supposed to see :), I see '12.45 EUR' where I would have expected '12.45 ↗'

Actually, I was thinking, would it be difficult to define your own format in the yaml?

Something like:

symbols:
   - xxx
     format: '%currency_symbol %value_comma %trending_arrow'

Where %value_period would be the alternative to deal with locale issues. I don't know if locale is even handled properly anyways, but I'd be happy with %value :p

Would even be cool to have %trending_arrow_colored to get a green/red/neutral arrow in this case.

anyway, would be nice to have more control over the formatting of the symbol, instead of trying to solve it with flags?

iprak commented 5 months ago

That is a neat idea but changing the unit_of_measurement based on trending status will mess up that stored data.

I do not believe that you can include icon as part of the state. The entity will have value, unit_of_measurement, icon and then some more values. You can observe them as "Settings > Entities", click the gear icon.

You can create your own template entity.

Entity value styling is dependent on the card being used, that cannot be controlled from the entity. If you are using auto-entities, then custom styling can be done.

I am flagging this issue as closed.

oliv3r commented 5 months ago

Right, you are only storing it as sensor data, and so you would have to store it as such.

So when you say:

That is a neat idea but changing the unit_of_measurement based on trending status will mess up that stored data.

means for existing data in the database? You are concerned of a breaking change? That's not unreasonable, and I suppose in this case, just a short-comming of hass in the way this information is handled.

But what I don't understand, what is the purpose of show_trending_icon: true? I don't see its effect anywhere? You wrote that

The unit_of_measurement` is still USD and that is what HomeAssistant displays.

In my case, it's EUR, but yes, that's what it displays.

I can introduce an optional setting to use currency_symbol instead of currency.

I think would however be useful I would think?