-
-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Currently, plotly-graph is not compatible with card-mod. I think there are two ways of making it compatible. A way which will work only with card-mod, and another which should make plotly-graph sufficiently similar to a vanilla card that card-mod and any other similar mod will work.
The first way is to call some card-mod primitive yourself so that it can do its magic. See https://github.com/thomasloven/lovelace-card-mod/blob/master/README-developers.md where AFAICT el should be the <ha-card/>, type should be what you want it to be (probably plotly-graph but you can use card which is what card-mod uses when it can hook into the ha-card itself as in the complicated method), styles should be config?.card_mod?.style || config?.style || "" where config is the whole card configuration, variables should be { config }, the unused should be null, and the last one I think should be false.
See https://github.com/thomasloven/lovelace-card-mod/blob/master/src/patch/ha-card.ts#L25 which is what card-mod wants ha-card to do when it is patched. I do not know if and when you are supposed to use the returned object to call its refresh() method as the patched ha-card does.
The other way is to make plotly-card extend LitElement instead of HTMLElement, as apexcharts-card does here: https://github.com/RomRider/apexcharts-card/blob/master/src/apexcharts-card.ts#L116. Another much simpler example to get inspiration from is https://github.com/thomasloven/lovelace-card-mod/blob/master/src/mod-card.ts whose role is only to wrap elements without an inner <ha-card/> into one.
But maybe the only thing that makes a LitElement work as-is with card-mod and your HTMLElement-based card not is that you do not provide any update() method ? Maybe adding a dummy update() would magically make things work ? I'll have to try if you do not get to do it before me.
Note that I never programmed in TypeScript before so I am very slow and naive. Sorry for that.