I am fairly new to Home Assistant, and apologize in advance if there is a simple answer to my question.
I have 2 separate entities for my iPhone battery; one from the HA Mobile App, and another from a sensor.
My problem has been that both entities do not always accurately show the battery level all the time. An example would be that my sensor today shows a last update of yesterday with incorrect battery level, while the entity from the Mobile app shows a update of 15 minutes ago and is accurate.
What I would like to do is create a card that shows the current battery level based on which ever entity received the latest update. Is this possible to achieve?
Probably you should create a template sensor with a value of the battery level from a sensor which was updated later.
Then the value of this template sensor may be displayed in any supported Lovelace card.
Btw, what kind of sensor do you use?
For mobile clients I am using basically Life360 integration which gives a battery info (battery level, charging or not). For 2 clients there are Mobile App sensors too but they do not seem providing the latest data.
this template will print the value of the last updated sensor. Replace sensor.iphone and sensor.ha with your entities. You can use it in a number ways… for creating a new sensor or whithin an automation, etc…
"{{ states('sensor.iphone') if states.sensor.iphone.last_updated|as_timestamp|float > states.sensor.ha.last_updated|as_timestamp|float else states('sensor.ha')}}"