Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accept templates as element for the field "shares" #185

Open
ggonmar opened this issue Oct 9, 2024 · 5 comments
Open

accept templates as element for the field "shares" #185

ggonmar opened this issue Oct 9, 2024 · 5 comments

Comments

@ggonmar
Copy link

ggonmar commented Oct 9, 2024

Proposing a nice enhancement:
I think it would be great if we could set the number of shares via a template, coming from an input number, or any other service:

- platform: avanza_stock
  stock:
    - id: 506278
      name: Stocks:Alibaba
      shares: {{ states("input_number.shares_of_alibaba") }}
      purchase_price: {{ states("input_number.purchase_price_alibaba") }} 

This way, one could easily update the sensor without having to dig into the code to change that value!

@oli737
Copy link

oli737 commented Oct 9, 2024

This would be really nice.

@claha
Copy link
Member

claha commented Oct 9, 2024

I'll see what I can do, the proper way would probably be if this component created that input_number sensor by itself. But the code for this is so far behind...

@claha
Copy link
Member

claha commented Oct 13, 2024

Got some time to test this today, it was easy to allow a template in the config and it gets the value correctly. What's left is to figure out how to make it responsive to changes made in the referenced states in the template

@oli737
Copy link

oli737 commented Oct 14, 2024

How to try it?

@claha
Copy link
Member

claha commented Oct 16, 2024

Here is the branch, but as I said above it will only pull the value of the template when HA is started

https://github.com/custom-components/sensor.avanza_stock/tree/shares-template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants