LAB02-Research / HASS.Agent

Windows-based client for Home Assistant. Provides notifications, quick actions, commands, sensors and more.
https://hassagent.lab02-research.org
MIT License
1.61k stars 74 forks source link

Feature: MQTT Battery % sensor as battery. #330

Open nealeydee opened 1 year ago

nealeydee commented 1 year ago

Hello.

In HA, to better show the battery percentage of my laptop on a Lovelace dashboard, I customise the sensor entity with the following:

sensor.spectre_x360_battery_charge_remaining_percentage: unit_of_measurement: '%' device_class: battery friendly_name: X360 Battery % icon:

By showing class as battery, and "unsetting" the icon, I can show the HA Battery icon as a dynamic icon, that changes size and colour based on the charged percentage:

Screenshot_2023-07-15-19-14-32-00_c3a231c25ed346e59462e84656a70e50

Could you possibly update the sensor device class and remove the defined icon? I think this shows the icons more intuitively.

Thanks for the HASS.Agent - my laptop and tablet batteries charge to 80% and stay charging when they are at 15%. This is a battery saver, end ensures that my batteries stay in good health and don't bulge, when the device stays plugged in for days.

A great tool for a home assistant junkie!

amadeo-alex commented 1 year ago

Hello, What kind of card are you using for the battery display? When I just add some battery devices, icons are always blue, only navigating to the details makes them "coloured": obraz obraz

In general I'd say this is a very good suggestion (very large assumption but most likely when the battery sensor was implemented, HA didn't colour the battery icons or the author wasn't aware of this fact) but we also need to think about how this will impact people actually using the icon values from those sensors.

nealeydee commented 1 year ago

Using a "Glance Card" (The one with the Pellet Stove title that I have to change as it has evolved) and a vertical stack standard entity in the card higher up, to the right of the "HP Pavilion" charger icon.

It maybe the unit of measurement, or that device class (but you refer to batteries - so I guess you alrady have device class = battery) or perhpas the defined icon (HASS.Agent defines the icon to use when it presents the sensor info) - by entering icon: and nothing after that - it seems that HA uses the default icon for a battery with % - which changes colour etc. Perhaps your battery's integration is defining the icon type - perhaps overriding it with a customize section in configuration.yaml may help?

I have a fullyKioskBrowser on an android tab I use to display the dashboard, and it has MQTT integration to send details to the MQTT broker, With this integration I saw the colored battery as soon as I added it, but had to do the following to get the HASS.Agent battery sensor to show in this way:

Nothing else special, other than adding this to my homeassistant: secontion of my configuration.yaml file :

customize:
    sensor.spectre_x360_battery_charge_remaining_percentage:
      unit_of_measurement: '%'
      device_class: battery
      friendly_name: X360 Battery %
      icon: