-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Plot data card - for making custom graph #868
Plot data card - for making custom graph #868
Conversation
|
Maybe. But from a backend perspective it feels strange to change the domain to use a different frontend card. I think it would be strange to have the Tibber sensor as something else than a sensor. We could also make it possible for the user to choose if (s)he wants a "normal" sensor where only the current state is shown or this new view with a graph. Then it would be strange if the domain changes according to this this. Then the entity_id will also change.
Maybe we should have an api/refactoring such that the frontend cards can be chosen independently of the domain?
Yes, when this pr is merged, the plot_data cards also needs to be updated |
This data should not be stored in the state machine. We should get it from an API. Cards are tied to a domain because of simplicity. If you want fancy stuff, use custom UI. It's otherwise unmaintainable for us as every card should be able to render every entity 🤔 |
i think this is such a generic feature, that it should be part of the official UI. Ok, how can such an API be implemented? Do we have any examples? (Btw, this is the same way we send forecast data to the frontend in the weather components) |
I'm not sure if it's a good example but I did something similar here https://github.com/home-assistant/home-assistant/pull/11866/files |
Would it make sense to allow the history component to make entities which show graphs for that entity ? I also want to make sure that we do not merge this before we merge the chart.js PR #429. It's almost ready to go. |
I would say that adding / removing history entities is a great use case to use the new Config Entries component home-assistant/core#12079 #861 (this example shows all that we need to do) |
That could work. Then we have to accept future dates in the database. And the frontend should plot future dates if it exists. |
I think we should keep this generic graph card separated from the history graph to make it more flexible. |
Yes. To use the history graph would work for my use case. |
We should not get a generic graph card. We always tie all frontend stuff to specific components. We can reuse building blocks that we use to build cards but won't have one card serve multiple domains. If you want other data than history data you will need a graph component, but how will platforms work for it? Maybe better for custom UI.. |
Ok, the history entities and using the history graph would work for my two use cases. But will we allow future dates to be added to database and visualized? |
I thought about this again and have to agree that I see this more as a custom component/ custom UI because the data is not directly bound to a component and the data + source + preferred UI can be so different. We have an open PR #850 (maybe we can get this in 0.63? ;)) for custom cards that can be used for this together with your card and component. Maybe we can also bring some glamour to the cookbook again and add links to some cool custom stuff but maybe this should be discussed somewhere else |
I have two use cases where I think this is required, and I think it should be part of the official code. For the electricity price in Tibber we are currently showing the current price and the previous prices. But the future prices are much more interesting, since they can be used for automation and planing of the heating/ electricity usage. (Use less electricity when the price is high). So I think we should support that sensor components can provide data, that are shown as a graph in the frontend. I see two issues with my proposed code:
(This is an important feature for me, so I really hope we can find a way to add it to the main repo.) |
|
|
Realized this already exists as history_graph |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think such switching cards by _plot_data attribute is a hack.
clear: both; | ||
} | ||
</style> | ||
<google-legacy-loader on-api-load='googleApiLoaded'></google-legacy-loader> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have already switched to chartsjs
<google-legacy-loader on-api-load='googleApiLoaded'></google-legacy-loader> | ||
<ha-card header='[[computeTitle(stateObj)]]'> | ||
<div class='content'> | ||
<div class='attribution attribution'>[[stateObj.state]] [[stateObj.attributes.unit_of_measurement]]</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have attribution
twice
<ha-card header='[[computeTitle(stateObj)]]'> | ||
<div class='content'> | ||
<div class='attribution attribution'>[[stateObj.state]] [[stateObj.attributes.unit_of_measurement]]</div> | ||
<div id='chart_id' hidden$="[[!attr._plot_data]]"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attr is not defined anywhere
@balloob @andrey-git
Yeah, you are probably right. But do you have any better solution?
More details in #868 (comment) |
Hi all! I cannot contribute to the development of this, but I just wanted to let you know that the ability to pull future data on the electricity is a huge deal. It really is the difference between doing simple on/off automations and a more intelligent design. Not sure I really understand the issues that have come up here, but couldn't´t this be solved by having another two sensor entities that always pulls data from 1 hour and 5 (as an example) into the future? |
Let's close this PR. We no longer use Google charts and a solid implementation requires some more changes. Maybe you can discuss this in the architecture repo first |
This will add a possibility for a component to make a custom graph. All components can provide a _plot_data dictionary as an attribute, and this will result in a custom graph in the frontend.
I am planing to use it in the backend like this: https://github.com/home-assistant/home-assistant/compare/tibber_plot?expand=1#diff-43f211c43ec818fda11c8afe6bab1ee5R95
This will allow the Tibber sensor to show the coming electricity prices, and not only the historic ones.
I guess other components could use this functionality too. And I already have an idea of adding another Tibber sensor, where this will be required.
(I have not done much frontend development, so hope to get some good feedback)