Invalid config for [sensor]: required key not provided @ data['platform']

This just appeared. I have not changed anything in my config.
Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 21.

I have nothing on line 21.

The next line is 22 which is sensor: !include sensors.yaml
If I remove the include sensors.yaml the error goes away.

Confused

The line numbers aren’t perfect. They can be pretty far off sometimes.

look in your sensors.yaml file for a config entry that doesn’t have a platform: key provided.

Or there may be an indentation error somewhere else in that file confusing the checker.

1 Like

Spot on.

I was trying to add a powercalc sensor. It was obviously wrong 🤦🏻

I’m struggling with inputting a power calc sensor.

You can also setup powercalc sensors with the config flow which was added a few weeks ago. So that may help if you are struggling with YAML.

1 Like

When someone reports a configuration error and claims “I didn’t change anything” … more often than not they did change something. :slight_smile:

I meant to say no changes in my configuration.yaml.
I didn’t Realise adding something in my sensors yaml would give me an error configuration.yaml.
I am on a learning process with HA but thanks anyway :roll_eyes:

1 Like

Your sensors.yaml is effectively part of your configuration.yaml file because within your configuration.yaml you have this statement:

sensor: !include sensors.yaml

What that means is that when Home Assistant processes the YAML in configuration.yaml it will get everything related to the sensor domain from the sensors.yaml file.

All this to say that configuration errors are typically caused by invalid changes made to Home Assistant’s configuration (which may be defined in one or more files).

1 Like

The way that includes are processed is that once the configuration.yaml is parsed it adds the included sections into the configuration just as if the included file information was added directly to the configuration.yaml itself at the point where the !include is placed.

That’s why line numbers are sometimes not correct. It depends on how the yaml parser sees the included code.

And it makes it even more confusing since the parser will ignore some content on some lines but not others. And it will sometimes even recognize the actual included file and reference the line numbers in that file itself (not the configuration.yaml file line numbers).

So, bottom line is that, yes, any configuration change anywhere in your config directory could end up throwing an error with a “configuration.yaml” line number as a reference even if the change wasn’t made there but in an included file.

So the line references can help but don’t take them as definitive clues as to where to look.

1 Like

Thank you for all the explanations. Much appreciated.

1 Like