Hey all, hoping you can help me with something seemingly simple. I’m pretty new with HA and am still trying to figure things out. I’ve got my home energy monitor synced to the HA and have set up a 30 minute running average sensor of my total energy usage called running_average_total_power
What I’m looking for is a way to grab the maximum value from that sensor between the hours of 1pm and 8pm. I tried to make an automation that runs at 8:00pm, but it doesn’t seem happy with running a -platform:statistics under the action: section.
I get the error : “Message malformed: extra keys not allowed @ data[‘action’][0][‘platform’]”
The statistics platform goes under the sensor section. You can’t make an automation using an integration configuration. Also, the statistics platform does not allow you to specify a static timeframe. It only allows you to set the max_age in relation to the current time.
Thanks for the direction. Having a bit of trouble still. I put this in my sensor.yaml and got it to give a check mark in the file editor. When I do check config before restarting i get the following error:
I am sure something is wrong with how i have this oriented or typed out.
Invalid config for [sensor.statistics]: extra keys not allowed @ data['minutes']. Got 420
extra keys not allowed @ data['template']. Got [OrderedDict([('trigger', [OrderedDict([('platform', 'time'), ('at', '20:00:00')])]), ('sensor', [OrderedDict([('name', 'Demand Max'), ('unique_id', 'demand_max'), ('state', "{{ state_attr('sensor.demand_stats', 'max_value') }}"), ('unit_of_measurement', 'W')])])])]
offset None should be format 'HH:MM', 'HH:MM:SS' or 'HH:MM:SS.F' for dictionary value @ data['max_age']. Got None. (See ?, line ?).
compare what I wrote to what you wrote. Your yaml format isn’t correct. Everything I wrote should go into configuration.yaml as-is. You’re trying to combine them, incorrectly.
and here is my configuration.yaml (have not touched this besides adding the include sensor.yaml line previously)
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensor.yaml
again I appreciate your help. I feel quite useless, as this HA stuff is new to me. Back in the day I did a ton of C++ and Java coding, but its been many years and I’m not as smart as I once was.
Well, again, compare what I wrote to what you wrote. What section does the statistics platform belong in? What section does the template sensor belong in? Hint: Both are listed in my example.
Since this was discussed, I believe there’s been a change to statistics platform. I’m trying to find the maximum daily solar energy procued in a year. Unfortunately this code only shows the maximum of each day
sensor:
- platform: statistics
name: "Max daily solar production over last year"
entity_id: sensor.symo_10_0_3_m_1_energy_day
state_characteristic: value_max
sampling_size: 730
max_age:
days: 365
- platform: statistics
name: "Date of max daily solar production over last year"
entity_id: sensor.symo_10_0_3_m_1_energy_day
state_characteristic: datetime_value_max
sampling_size: 730
max_age:
days: 365
Then displaying on the front end using a template
type: entities
entities:
- type: custom:template-entity-row
icon: mdi:solar-power
name: Max solar production
state: >-
{{ (states('sensor.max_daily_solar_production_over_last_year') | float /
1000) | round(1)}} kWh on {{
as_timestamp(states('sensor.date_of_max_daily_solar_production_over_last_year'))
| timestamp_custom('%a %-d-%b-%Y') }}
I solved this, my energy meter updates every 10 seconds, so I had to increase sample size to 3,153,600. Thinking there must be a better way to do this where HA just stores a single number for the max value.