New sensors command line commands

I am trying to make two sensors for myself. One to calculate the size of the folder (it used to work), and the other to get a list of files in the directory. But they don’t work. Can you tell me why? The state is unavailable.
My sensors in packedges.

    command_line:
      - sensor:
          name: folder_cam_captures_size
          command: "du -sh /config/www/cam_captures | awk '{print $1}'"
          unit_of_measurement: "KB"     
          unique_id: folder_cam_captures_size

and anothe (It was suggested to me by Chat GPT)

    command_line:
      - sensor:
          name: file_list
          command: "ls /config/www/cam_captures/2023-07-11"
          scan_interval: 300
          value_template: "{{ value.split('\n') }}"
          json_attributes:
            - files

By the way, what is the correct way to register two sensors together in one package?


command_line:
  - sensor:
      .....
  - sensor:
      .....
1 Like

Thank you. That’s helpful. But the main thing is that these sensors do not work for me. Even separately. Maybe the commands themselves are spelled wrong somehow?

Sorry I need to be at my computer to help you with that. Perhaps someone else will chime in. :slightly_smiling_face:

still relevant