Moving sensors to sensor.yaml

Chaps; I had this working in configuration.yaml
and it created a sensor for me

command_line:
   - sensor:
       name: plex file history
       command: 'cat /config/bruce/file/plex.txt'

I’m trying to move this to sensor.yaml but I can’t get either the formatting correct or the syntax as it won’t create a sensor for me.

In configuration.yaml I have include

sensor: !include sensor.yaml

And my sensor.yaml is

- platform: command_line
  sensors:
    name: plex file history
    command: 'cat /config/bruce/file/plex.txt'

It passes Dev Tools / Check configuration with no errors but just doesn’t create the sensor
Please help, believe me I’ve trawled the forums but just can’t get this working.

That is not valid syntax. That was how it used to be done but you can not use it any more.

Command line sensors are no longer part of the sensor integration. They are part of the command line integration. The only way to do it is:

command_line: !include command_line.yaml

command_line.yaml

- sensor:
    name: plex file history
    command: 'cat /config/bruce/file/plex.txt'
1 Like

Hey Tom

Awesome mate; got to go and do “Taxi of Dad duties”; but will try as soon as I get back
Thanks so much mate, I NEVER would have found that

This worked, thanks mate