To begin, I’m new to HA - attempting to move over from OpenHAB. In my current config, I have a ‘switch’ entity that has a (power consumption) value associated with it. I want to extract the power consumption value and make it a ‘sensor’ entity so that I can graph it. To this end I have setup the following configuration in “sensor.yaml”, after having checked it in the Template Editor:
The problem is that I have no evidence that this configuration results in a sensor being created. I don’t see a sensor called ‘american_fridge_power’ appear anywhere ie not in the ‘Entities’ list. But neither do I have any evidence that the sensor is not being created - ie there’s nothing in the log file to indicate a problem.
So what am I doing wrong? Have I missed a step out somewhere? Or has the sensor been created and I’ve not yet found it.
Also use the format shown above to extract the attribute. It will not generate errors while the sensor is initialising after a restart.
One other bit of advice. If that switch is really on a fridge you might want to search out the custom restriction-card to prevent it being turned off accidentally.
If you look at Tom’s code you will see that there is a sensor: (implicit as you had to create an include in your config to point to this file) There can only be one sensor: heading (unless you use packages, but you are not anywhere near using those yet)
And under that you have the - platform: template (again only one of those)
And under that you have a sensors: heading (again only one of those)
Then you list your sensors, your first being : - american_fridge_power:
So in effect you have created a sensor under sensor,template,sensors,american_fridge_power it needs to be unique and implicit in that is the uniqueness of it’s path address (again ignore packages for the moment)
### Sensor.yaml
### Plugwise config to log power use
- platform: template
sensors:
american_fridge_power:
friendly_name: "American Fridge Power"
unit_of_measurement: 'Watt'
value_template: "{{ state_attr('switch.americanfridge', 'current_consumption') }}"
But still no joy - I think. I expect to be able to find a Sensor entity with the name ‘american_fridge_power’. But there’s still no such entity created. Note that the Switch entity is present.
Good point. But I’m a long way from such considerations at the moment. Still can’t get HA to read all my plugwise circles - only 10 from 18 and then unreliably. Also can’t get it to read my SMA inverter. All these things were working in OpenHAB so I assume that I must be able to reach a similar configuration with HA.
Did you do a configuration check before restarting? - turn Advanced mode on in your profile if you do not see this on the configuration / server controls page.
Yes. I always run a config check before restarting - saves a lot of time.
Yes. I restarted a couple of times. I also forced an error in the sensors.yaml file to makes sure that it was being read.
Yes. I checked the config with the Template Editor. Result below:
### Sensor.yaml
### Plugwise config to log power use
- platform: template
sensors:
american_fridge_power:
friendly_name: "American Fridge Power"
unit_of_measurement: 'Watt'
value_template: "90.1"
The fact that there’s a value for the “value_template” would indicate that at least the source entity is present and possesses a current value.
Yes, there are errors in the home-assistant.log file. Most have to do with the plugwise circles that is cannot read at the moment. This is a problem I was postponing till later. The ‘American Fridge’ circle is working and showing a value. There are two lines in the log that might be relevant:
Those errors are relevant. The problem is that you have both sensor: and group: defined more than once in your configuration file. These are preventing your config from loading completely.
Fixing these issues will probably solve all the other problems you are having.
Then why is not an Error instead of a warning? Errors I take seriously, warnings less so. If a double sensor entry prevents something from working then it’s an error. If it’s merely a sub-optimal configuration that still works, then a warning is suitable.
I dunno, maybe you should take it up with the guy who wrote the config checker, and who keeps it up to date with the ongoing changes in HA as it develops through its beta releases.
I think he does a pretty damn good job as it is and you were warned specifically.
Your config was still loading, just not all of it. That’s sub optimal in my books. If it prevented your config from loading at all then it would be an error.