I don’t know what you’re doing wrong, but you are doing something wrong because the two options I mentioned (above) are clearly documented and used successfully by others (see posted link).
EDIT
Read you post again and if you meant you tried to literally include a last_reset option in the MQTT Sensor’s configuration, then that will definitely not work. You must use the two options I described above and they will be used to generate a last_reset attribute for the sensor.
If I set it in the mqtt sensor I get:Invalid config for [sensor.mqtt]: Single-level wildcard must occupy an entire level of the filter for dictionary value @ data['last_reset_topic']. Got datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc). (See /config/configuration.yaml, line 32). Please check the docs at https://www.home-assistant.io/integrations/mqtt
I saw that there were changing the last_reset stuff in 9.0 but I am not sure that will help whatever I have done wrong since I am able to see it in the energy configuration and set it up. I think I must be missing something else. I will try to swap to the " last_reset_value_template" thing here in a few minutes and see if that changes the outcome.
So I did not get an error using the last_reset_value_template and last_reset_topic, but now the sensor is not something I can use in the energy management configuration. I removed my house consumption and solar production sensors and now neither of them are available to add back unless I go back to my global config I had posted in my last post…
Well… I re-added it again, and now its appearing… I can see that data is coming in to that sensor but it was before. Now I guess I have to wait an hour or two? or is there another way to see that it is at least collecting data properly?
I believe it collects data every hour so, yes, you’ll need to give it a bit of time before the graph is updated.
Once you have confirmed it is operating properly, please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. It will also place a link below your first post that leads to the solution post. All of this helps users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.
So far after nearly 2hrs there is nothing different in the energy panel. There is no animation in the energy distribution, no numbers associated with the sources, and nothing in the graphs. I am seeing data on those entities regularly. Maybe I am not patient enough, but thats what I thought last time when I had it configured using the globals.
If you have never seen anything in the graph ever, even after adding several different sensors, then that’s a separate problem (from merely a misconfigured MQTT Sensor). It’s difficult to say what would cause that (I can’t replicate the problem).
I’ve added a channel plus added the the two sensors to the individual channels to see what happens and nothing on the energy dashboard. I can click on them in the individual and see the data in the cards but nothing calculates. Thats why I feel it’s a black box, I can find nothing in the documentation on how this thing works in order to understand what I am doing wrong. Thanks for trying.
Not sure what you mean by “channel” (I haven’t see that term used in the Energy integration). Did you add sensor.solar_generated and sensor.house_consumption under “Individual Devices”?
Yeah sorry, that terminology is from the Dashbox/GEM energy monitor I have. A channel is a CT device on a circuit. I did add solar_generated and house_consumption under individual devices as a test and see nothing on the panel. I feel like something is not triggering the longer term storage/statistical stuff as I also added a stat card and do not get what I am expecting. The data I am getting is kwh since the last packet sent. Not sure if that is what HA is expecting?
Yes, it has to be energy, expressed in Wh or kWh, otherwise it doesn’t qualify as an acceptable resource for the Energy integration (some users mistakenly try to include power sensors, expressed in W or kW, but those are ignored by the integration).
So this might be something that I should have remembered when I was asking this question… Logs… for some reason this slipped my mind until I was looking today… this is the error I am getting and I was unable to find an answer when searching for one:
Logger: homeassistant.components.recorder
Source: components/sensor/recorder.py:283
Integration: Recorder (documentation, issues)
First occurred: 12:12:00 PM (1 occurrences)
Last logged: 12:12:00 PM
Error while processing event StatisticsTask(start=datetime.datetime(2021, 8, 29, 17, 0, tzinfo=datetime.timezone.utc)): unsupported operand type(s) for +=: 'NoneType' and 'float'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 623, in _run_event_loop
self._process_one_event_or_recover(event)
File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 632, in _process_one_event_or_recover
self._process_one_event(event)
File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 738, in _process_one_event
self._run_statistics(event.start)
File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 721, in _run_statistics
if statistics.compile_statistics(self, start):
File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 303, in wrapper
return job(instance, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 154, in compile_statistics
platform_stats.append(platform.compile_statistics(instance.hass, start, end))
File "/usr/src/homeassistant/homeassistant/components/sensor/recorder.py", line 283, in compile_statistics
_sum += new_state - old_state
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'float'
The Energy integration is summing the values of several sensors and, at one point, at least one of the sensors failed to have a proper numeric value (‘NoneType’ which is neither int or float). It can’t add a float value to NoneType and that’s what generated the error message.
Perhaps one of your energy sensors has an unknown or unavailable value in its history.
Is there a way to see the payload history? I have monitored it via the sender (DashBox) but nothing ever looks weird to me. Just set the mqtt logging level in HA to debug and restarted as I am thinking thats the next step. I have not really seen what the payload really looks like and I am not sure something like MQTT explorer can do that? seems to want to talk to a broker not be one?
A history of values is recorded for each entity (unless you explicitly exclude it in the recorder configuration). Click the sensor in the Lovelace UI and a popup will appear showing its history.
A value of 0 isn’t a problem it’s when a value isn’t recognizable as being numeric (‘NoneType’) that’s causing the error message. It might be rendered as a gap in the graph and that’s not going to be easy to find using that graph.
You could try the nuclear option and purge all data from the database. Alternately, if you know your way around SQL, you can surgically delete only the values belonging to the sensor(s). However, that’s not something I will coach you through.
SQL is not an issue here, I am just not familiar with how one gets to the database instance. I’ll look around but if you have a hint by all means I am listening