Hi All,
i am fairly new to HA dev. Currently i am working on a custom component which includes two entities, a switch and a climate entity.
What is the best way to share some variables(states) between these two entities? For example, when the climate temperature gets updated, the switch should get notified.
Should I create a base class for both of them ?
Thanks for your help!
A base class will just inherit the vars and methods for each entity, it will not share any of the class instance vars between them.
I would use a DataUpdateCoordinator (DUC) which is passed into each entity. In your DUC, you can have a many vars as you like and each entity can update and read them.
My example integrations show how to do this if it helps. Look at the msp_integration_101_template one for the basic way of doing.