When to add to config.yaml or sensor.yaml?

I’m still playing around with things am I’m starting to get the hang of things,but I do have a question. I’ve created a template so I can see the battery level of the Wyze sensors,so I figured it goes into the sensor.yaml. I put it there and it didn’t work. I put the file in the configuration.yaml under a sensor I had already and it worked. Are there certain times that the template goes into one or another? If I missed that info,sorry for that. My config looks like this…

  • platform: template
    sensors:
    laundry_motion_battery:
    friendly_name: ‘Laundry Motion Battery’
    value_template: ‘{{ state_attr(“binary_sensor.wyzesense_77a5d940”,“battery_level”) }}’
    unit_of_measurement: ‘%’

assuming you mean

- platform: template

with no indenting and you have:

sensor: !include sensor.yaml

in configuration.yaml

Then it will work in either location. But you can’t define any sensors in there if you do this… they will all go in the sensors.yaml file (or in packages but that’s another topic)

HA basically just adds all the components into one big component internally. The only reason to split stuff is for your personal benefit… HA doesn’t care.

Thanks David. That makes sense now.

1 Like

Well,when I try to add sensor: !include sensor.yaml to my configuration file at the end of the files,I get this error…Invalid config for [group]: value should be a string for dictionary value @ data[‘group’][‘sensor’][‘entities’]. Got None. (See /config/configuration.yaml, line 106). The sensor: !include sensor.yaml is at the end of file after groups,so It looks like it’s trying to tie it into the groups. Are there spacing requirement or something else I’m missing? Thanks

do you have any other

sensor: 

in your configuration.yaml file?

I do. I have it for my motion and door sensors.

Well you can’t do that!
You can only have ONE sensor: section.

So EITHER move all your sensors to sensor.yaml OR create a package just for the Wyze ones.

To do that, create a folder called packages.
In configuration.yaml make sure you see this:

homeassistant:
  packages: !include_dir_named packages

Then create a wyze.yaml with this:

sensor:

etc.

Note if you are using a sensor.yaml file DO NOT have a sensor: in that file and don’t indent…

Thanks David. I will try that.

1 Like

Wow. I’m liking this package thing. I’ve got my wyze sensors,ect done. Makes things alot easier to find. I do have a 2 Eufy cameras that I used - platform: generic for,but I’m getting this error when trying to do a package.

Platform error sensor.generic - No module named ‘homeassistant.components.generic.sensor’
Platform error sensor.generic - No module named ‘homeassistant.components.generic.sensor’

Ideas? Thanks

make sure you have

sensor:

in that file…

The way packages work, you need to structure them like configuration.yaml
So you can include EVERYTHING associated with a component in a package so it can include scripts, automations, sensors… everything.
In the package the Eufy would look like this:

sensor:
  - platform: generic

etc…

Packages rock!

Got around to doing it and this is popping up now…

Platform error sensor.generic - No module named ‘homeassistant.components.generic.sensor’
Platform error sensor.generic - No module named ‘homeassistant.components.generic.sensor’
Platform error sensor.generic - No module named ‘homeassistant.components.generic.sensor’
Platform error sensor.generic - No module named ‘homeassistant.components.generic.sensor’
Platform error sensor.generic - No module named ‘homeassistant.components.generic.sensor’

Made a Eufy.yaml with this…
sensor:

  • platform: generic
    Thats is a dash,not sure why it pops up in the message as a dot.

Edit: I got it. I had to add camera:

It would be a

- if the code would be formatted

you can do that with the </> button