custom-components / sensor.avanza_stock

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

monitored_conditions does not work #115

Closed hajo62 closed 3 years ago

hajo62 commented 3 years ago

I'm not sure if it's a bug or if I missunderstood the monitored_conditions option:

As a start and to test I have added:

  - platform: avanza_stock
    stock:
      - id: 4175
        name: IBM 
        shares: 1
        conversion_currency: 18987
        invert_conversion_currency: true
        purchase_date: 2008
        purchase_price: 75
        currency: €
    monitored_conditions:
      - change
      - changePercent
      - currency
      - name

I had expected to see just those 4 attributes but I see lots more:

grafik
claha commented 3 years ago

Yes you get a little more than what you ask for. Monitoring change implies monitoring changeOneWeek etc. Same for changePercent. TotalChange* is shown when you have set to monitor change and also specified shares. I could probably add something to the readme to clarify that.

claha commented 3 years ago

Setting a purchase_price also gives extra attributes profitLoss and profitLossPercentage

hajo62 commented 3 years ago

Thanks. If you find some time clarifying in the readme might be helpful.

In my case, I'm interested (beside other attributes) in purchase_price, profitLoss and profitLossPercentage, but I would find it more clear to explicitly define the attributes - atleast if someone uses the monitored_conditions option and implicitely add other attributes only if that option isn't used.

claha commented 3 years ago

I see your point and agree that woud be a better design. Changing this now would be a breaking change, I will see if I can add some deprecation warning about implicit attributes (that they will need to be defined in the monitored_conditions in a future release). Hopefully pepople will notice the warning and make the change before they are removed. #118

I hope this doesn't stop you from doing what you actually want to achive.