custom-components / sensor.avanza_stock

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

Speify to scan only during trading days and hours? #126

Closed qerim closed 2 years ago

qerim commented 2 years ago

I have the following config:

- platform: avanza_stock
  scan_interval: 60
  stock:
    - id: 365296
      name: avanza_stock_vusa
      conversion_currency: 155735
    - id: 29747
      name: avanza_stock_v

However, as you can see, it's scanning every 60 minutes even after trading hours, which produces these flat line graphs:

image

Any way to get this to stop scanning after trading halts?

claha commented 2 years ago

I dont know if this information is available from the avanaza api, habe you seem the information on the webpage somewhere? Or do you have any ideas on how to detect this automatically? Other integrations doing something similar?

I guess one way would be to have a binary sensor (stock_market_open) as an optional argument which must be true for the update to happen. But this would then have to be controlled by the user when to set this to true/false.

I am also not sure what will hapoen with the graph if there is a few hours without updates, if the x-axis is time I guess there would still be a long flat line

qerim commented 2 years ago

@claha I just came across this. It seems to be able to allow you to specify when to update the sensor values as you said. Thanks :)