core: Command line sensor warns about needing `device_class` set with temperature `unit_of_measurement` but does not support it

The problem

It appears that command line sensors don’t support the device_class tag and is throwing a warning about needing them for temperature values. Adding the device class to the customize.yaml also doesn’t fix the warning.

What is version of Home Assistant Core has the issue?

2021.9.7

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Command Line Sensor

Link to integration documentation on our website

https://www.home-assistant.io/integrations/sensor.command_line/

Example YAML snippet

configuration.yaml

    - platform: command_line
      name: cpu_0_temperature
      command: cat /config/cpu0temp.txt
      unit_of_measurement: "°C"
    
    - platform: command_line
      name: P8J8XDVR_Temperature
      command: cat /config/P8J8XDVRtemp.txt
      unit_of_measurement: "°C"

    - platform: command_line
      name: 200703809989_Temperature
      command: cat /config/200703809989temp.txt
      unit_of_measurement: "°C"

    - platform: command_line
      name: P8G1G7YR_Temperature
      command: cat /config/P8G1G7YRtemp.txt
      unit_of_measurement: "°C"

    - platform: command_line
      name: ST4000VN008_Temperature
      command: cat /config/ST4000VN008temp.txt
      unit_of_measurement: "°C"

customize.yaml

sensor.cpu_0_temperature:
  friendly_name: CPU temperature
  device_class: temperature
sensor.p8g1g7yr_temperature:
  device_class: temperature
sensor.st4000vn008_temperature:
  device_class: temperature
sensor.p8j8xdvr_temperature:
  device_class: temperature
sensor.200703809989_temperature:
  device_class: temperature

Anything in the logs that might be useful for us?

Entity sensor.cpu_0_temperature (<class 'homeassistant.components.command_line.sensor.CommandSensor'>) with device_class None reports a temperature in °C which will be converted to °F. Temperature conversion for entities without correct device_class is deprecated and will be removed from Home Assistant Core 2022.3. Please update your configuration if device_class is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+command_line%22
Entity sensor.p8g1g7yr_temperature (<class 'homeassistant.components.command_line.sensor.CommandSensor'>) with device_class None reports a temperature in °C which will be converted to °F. Temperature conversion for entities without correct device_class is deprecated and will be removed from Home Assistant Core 2022.3. Please update your configuration if device_class is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+command_line%22
Entity sensor.st4000vn008_temperature (<class 'homeassistant.components.command_line.sensor.CommandSensor'>) with device_class None reports a temperature in °C which will be converted to °F. Temperature conversion for entities without correct device_class is deprecated and will be removed from Home Assistant Core 2022.3. Please update your configuration if device_class is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+command_line%22
Entity sensor.200703809989_temperature (<class 'homeassistant.components.command_line.sensor.CommandSensor'>) with device_class None reports a temperature in °C which will be converted to °F. Temperature conversion for entities without correct device_class is deprecated and will be removed from Home Assistant Core 2022.3. Please update your configuration if device_class is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+command_line%22
Entity sensor.p8j8xdvr_temperature (<class 'homeassistant.components.command_line.sensor.CommandSensor'>) with device_class None reports a temperature in °C which will be converted to °F. Temperature conversion for entities without correct device_class is deprecated and will be removed from Home Assistant Core 2022.3. Please update your configuration if device_class is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+command_line%22

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 22 (7 by maintainers)

Commits related to this issue

Most upvoted comments

This is still an issue in 2022.3.7. It can be easily reproduced with the following config:

sensor:
  - platform: command_line
    name: Test Command Line Sensor
    command: echo 1
    unit_of_measurement: "°C"

which results in the following log output:

2022-03-25 14:54:19 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.test_command_line_sensor (<class 'homeassistant.components.command_line.sensor.CommandSensor'>) with device_class None reports a temperature in °C which will be converted to °F. Temperature conversion for entities without correct device_class is deprecated and will be removed from Home Assistant Core 2022.3. Please update your configuration if device_class is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+command_line%22

but it is not possible to do what the log entry asks because there is no device_class attribute for command line sensors.

I changed the title so its clear its about the warning.