Some sensors not working when specified in sensors.yaml

Hi

I am running the latest HA release and am having some issues with sensors not appearing when specified in my /includes/sensors.yaml

I have two in there now that work fine, being system monitor and an efergy energy sensor, however i cannot get the following three to work

  • Spotify
  • Octoprint
  • Speedtest

Using Octoprint as an example, here is how i had it setup in /includes/sensors.yaml

#Octoprint
- platform: octoprint
  host: 192.168.100.94
  api_key: !secret octoprint_api
  name: Cocoon
  bed: false
  number_of_tools: 1
  sensors:
    monitored_conditions:
      - 'Current State'
      - 'Temperatures'
      - 'Job Percentage'
      - 'Time Remaining'
      - 'Time Elapsed'

No matter what i try, if i specify these in sensors.yaml, they just dont load, despite config checker validating all is well

If i configure these in configuration.yaml, they work 100%

Have you checked the log to see if there are any clues ?

Yeah, i dont see anything

Can you share the part of your configuration.yaml that shows the include statement?

https://paste.ubuntu.com/p/Hp46d8Xkst/

Octoprint doesn’t go in the sensors.

Most components generate sensors. The job of sensors.yaml is for you to combine other devices/entities/sensors into your own sensors. It’s not the place to define what other component’s sensors are supposed to be.

Like you noticed, you need to define it all in configuration.yaml.

# in configuration.yaml
# Octoprint
octoprint:
  host: 192.168.100.94
  api_key: !secret octoprint_api
  number_of_tools: 0
  bed: false
  number_of_tools: 1
  sensors:
    monitored_conditions:
      - 'Current State'
      - 'Temperatures'
      - 'Job Percentage'
      - 'Time Remaining'
      - 'Time Elapsed'

The octoprint platform will generate your sensors from here. The only thing for octoprint you would put in the sensors.yaml would be templates to convert things should you desire.

For example, here is what I have to convert F to C for my sensors.

- platform: template
  sensors:
    hotend:
      friendly_name: 'Hotend Actual'
      unit_of_measurement: "°C"
      value_template: "{{ ((states.sensor.anycubic_i3_mega_actual_tool0_temp.state | float-32) | float*(5/9)) | round(2) }} °C"

    bed:
      friendly_name: 'Bed Actual'
      unit_of_measurement: "°C"
      value_template: "{{ ((states.sensor.anycubic_i3_mega_actual_bed_temp.state | float-32) | float*(5/9)) | round(2) }} °C"

    hotend_target:
      friendly_name: 'Hotend Target'
      unit_of_measurement: "°C"
      value_template: "{{ ((states.sensor.anycubic_i3_mega_target_tool0_temp.state | float-32) | float*(5/9)) | round(2) }} °C"

    bed_target:
      friendly_name: 'Bed Target'
      unit_of_measurement: "°C"
      value_template: "{{ ((states.sensor.anycubic_i3_mega_target_bed_temp.state | float-32) | float*(5/9)) | round(2) }} °C"

I have this because I want all of the temps to be in Celsius, but HA is configured for U.S. measurement for everything else.

You would replace ‘sensor.anycubic_i3_mega_’ with your actual printer name.

2 Likes

So does everything need to exist in configuration.yaml?

I don’t know what exactly you mean with this.

If you use packages, you can put the whole configuration for octoprint inside a package together with other stuff.

You could also add this to configuration.yaml
octoprint: !include octoprint.yaml and create a file octoprint.yaml in the same directory as configuration.yaml and put the config in there.

The things you like to include (spotify, speedtest and octoprint) are not sensors and don’t belong in the sensor: part of the configuration. However, some of them may create automatically some sensors when you configure them.

I recommend reading up on packages from the link above and about splitting up configuration as well to get a better understanding.

Oh

So each include line should be for each item
So one for Octoprint with a corrosponding yaml, one for speedtest, one for spotify etc etc?

If you don’t use packages, then you need to have an include for each category, so as you said one for octoprint, one for speedtest etc.

With packages you could include them all in one package or in multiple packages. E.g. I have a package security system, which holds all sensors, binary_sensors, input_booleans, integrations etc. that belong to security.

1 Like

you dont happen to have it in a github i can see all the layout for

i find looking at other configs easier for me to understand it all

thanks for your help though

I do :wink: check here