Custom Sensor Entities not available from configuration.yaml file

Hi,

I have home assistant setup in a docker container hosted on a raspberry pi.

I was trying to create a card that checks for available Pi OS updates.

on my configuration.yaml file I have added :

sensor:
  - platform: command_line
    name: Raspberry Pi Updates
    command: "bash -c 'sudo apt update > /dev/null && apt list --upgradable 2>/dev/null | grep -v \"Listing...\" | wc -l'"
    scan_interval: 3600
    unit_of_measurement: "updates"

And on my HA dashboard, to create the card I am using the .yaml

type: entity
entity: sensor.raspberry_pi_updates
name: Raspberry Pi OS Updates
icon: mdi:raspberry-pi
state_color: true

but when saving my yaml on my dashboard

“Entity not available: sensor.raspberry_pi_updates”

is shown.

So I think that for some reason my HA instance isn’t reading the sensor correctly from my configuration.yaml file for some reason?

I “think” my code should work. But not 100% sure.

Can somebody please help, as to why the “entity is not available”?

or

mayby provide a simple test sensor that can be created in my configuration.yaml file and the associated card .yaml to check if it is working, and it might just be the case of my incorrect code…

I have rebooted my HA instance after amending the configuration.yaml file.

Thanks in advance!