Battery Status of laptop running Home Assistant OS in Docker

I followed home assistant battery configuration

# Loads default set of integrations. Do not remove.
default_config:
# Example configuration.yaml entry
sensor:
  - platform: linux_battery
# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

restarted home assistant:

$ sudo docker stop homeassistant
homeassistant
$ sudo docker start homeassistant
homeassistant
$

here is my battery information:

g$ upower -i /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               Hewlett-Packard
  model:                Primary
  power supply:         yes
  updated:              Sun 09 Nov 2025 09:01:12 PM UTC (0 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    warning-level:       none
    energy:              25.764 Wh
    energy-empty:        0 Wh
    energy-full:         25.764 Wh
    energy-full-design:  25.764 Wh
    energy-rate:         0 W
    voltage:             12.576 V
    charge-cycles:       231
    percentage:          100%
    capacity:            100%
    technology:          lithium-ion
    icon-name:          'battery-full-charged-symbolic'
  History (charge):
    1762722072  100.000 fully-charged
    1762722072  0.000   unknown
  History (rate):
    1762722072  0.000   unknown

then I tried this:


# Loads default set of integrations. Do not remove.
default_config:
# Example configuration.yaml entry
- platform: linux_battery
  name: Host battery monitor
  battery: 0 <-- your battery number default is 1
  system: linux <-- linux is the default you can also not applie
# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
$ sudo docker restart homeassistant  

It does not work as described in home assistant.
Can someone please guide me into the right direction.

I want to know whether or not the laptop is connected to AC and also what the battery % is when it is not.

Comment: Not sure what your underlying platform is, but in another life I know that Windows WMI calls will also get you this info.

Right now you are telling HA configuration ( in the docker container) to look for battery 0 and report that info.
Does your HA container have access to the device you want to monitor? If it cannot access the battery_BAT0, it cannot report on it.
Also, the default setting for number if battery is 1, did you change it on purpose to 0 for testing?

# Loads default set of integrations. Do not remove.
default_config:
# Example configuration.yaml entry
- platform: linux_battery
  name: Host battery monitor
  battery: 0 <-- your battery number default is 1
  system: linux <-- linux is the default you can also not applie
# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

ubuntu server

~$ upower -i /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               Hewlett-Packard
  model:                Primary
  power supply:         yes
  updated:              Mon 10 Nov 2025 10:32:55 PM UTC (20 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    warning-level:       none
    energy:              25.764 Wh
    energy-empty:        0 Wh
    energy-full:         25.764 Wh
    energy-full-design:  25.764 Wh
    energy-rate:         0 W
    voltage:             12.565 V
    charge-cycles:       231
    percentage:          100%
    capacity:            100%
    technology:          lithium-ion
    icon-name:          'battery-full-charged-symbolic'
~$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          (null)
  power supply:         no
  updated:              Thu 01 Jan 1970 12:00:00 AM UTC (1762814001 seconds ago)
  has history:          no
  has statistics:       no
  unknown
    warning-level:       unknown
    battery-level:       unknown
    percentage:          0% (should be ignored)
    icon-name:          '(null)'

The lack of a valid date and empty data in your variables would tend to indicate the second part is not being called or is isolated from the machine.