andrew-codechimp / HA-Battery-Notes

A Home Assistant integration to provide battery notes of devices
MIT License
458 stars 85 forks source link

Battery+ sensor missing for some devices #1672

Closed chemelli74 closed 2 months ago

chemelli74 commented 2 months ago

System Health details

System Information

version core-2024.5.4
installation_type Home Assistant Container
dev false
hassio false
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 4.4.302+
arch x86_64
timezone Europe/Rome
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4996 Installed Version | 1.34.0 Stage | running Available Repositories | 1395 Downloaded Repositories | 22
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Dashboards dashboards | 2 -- | -- resources | 12 views | 14 mode | storage
Recorder oldest_recorder_run | 11 maggio 2024 alle ore 18:43 -- | -- current_recorder_run | 19 maggio 2024 alle ore 16:55 estimated_db_size | 988.02 MiB database_engine | sqlite database_version | 3.44.2
Spotify api_endpoint_reachable | ok -- | --

Checklist

Describe the issue

I noticed that some devices have the battery+ sensor, some others not.

Reproduction steps

  1. Install integration via HACS
  2. Add battery_notes: to configuration.yaml
  3. Restart HA
  4. Check created sensors

Debug logs

No response

Diagnostics dump

No response

andrew-codechimp commented 2 months ago

Hi, this depends on the device. Only devices with a battery percentage will be picked up and a Battery+ created. If your device has multiple entities that are batteries, like a voltage, low/normal or something else then try removing the device from battery notes and adding it back with the new Entity method, which will allow you to specify the battery entity directly, it can get confused with multiple battery entities.

chemelli74 commented 2 months ago

Hi, doesn't looks like this is the case:

image

andrew-codechimp commented 2 months ago

OK, the Shelly integration had an issue a long time ago where the battery wasn't added properly. Can you remove it from Battery Notes, remove it from the Shelly integration, then re add it.

See this issue for someone else with the same problem with a Shelly battery device. https://github.com/andrew-codechimp/HA-Battery-Notes/issues/1622

chemelli74 commented 2 months ago

Interesting, I run jq -e ".data.entities[]| select(.entity_id==\"sensor.sensore_acqua_battery\")" core.entity_registry

and found the issue:

{
  "aliases": [],
  "area_id": null,
  "categories": {},
  "capabilities": {
    "state_class": "measurement"
  },
  "config_entry_id": "070664e60231bf2de016840aa386d429",
  "device_class": null,
  "device_id": "bb9132f258b97b7ddbbe63c8cea0c347",
  "disabled_by": null,
  "entity_category": "diagnostic",
  "entity_id": "sensor.sensore_acqua_battery",
  "hidden_by": null,
  "icon": null,
  "id": "3cd48ac6b624a061669b7e845f36fc5e",
  "has_entity_name": false,
  "labels": [],
  "name": null,
  "options": {
    "conversation": {
      "should_expose": false
    }
  },
  "original_device_class": "battery",
  "original_icon": null,
  "original_name": "Sensore Acqua battery",
  "platform": "shelly",
  "supported_features": 0,
  "translation_key": null,
  "unique_id": "xxxxxx-device-battery",
  "previous_unique_id": null,
  "unit_of_measurement": null
}
andrew-codechimp commented 2 months ago

Yes, seems to be an issue with the early Shelly integration that didn't set the "unit_of_measurement": "%" correctly. It's safe to modify entity_registry value and do a HA restart to get that properly recorded if you don't want the pain of re-pairing, I just don't like to suggest that for people unfamiliar with JSON, but by your use of jq there I'm guessing you're a hard core HA user!