I cant correlate the blank phase in the chart to a restart I did, or anything else really, the rest of my sensors show fine. Including the sensor this template is based on:
I’ve added all of these sensors to the recorder. Why would this gap exist, and how come the state is ‘Unknown’? This same behavior is shown on all of these trigger based template sensors.
update
no, its positive, these sensors dont survive a restart. which currently makes them useless for my goal here, recording daily power consumption/usage in a sensor.
Got the following error when updating to 2021.4.4:
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
home-assistant-frontend==20210407.3 from https://files.pythonhosted.org/packages/1e/29/13a7ee41fdc63f2ad07fc0c7c664ffd8c8e4319764d33d95bf7727bc25b9/home-assistant-frontend-20210407.3.tar.gz#sha256=b9c7b04b5f7791bbe593843ee481184fab1f27f1f4d3abb2d22222f141ceccfa (from -c /srv/homeassistant/lib/python3.8/site-packages/homeassistant/package_constraints.txt (line 19)):
Expected sha256 b9c7b04b5f7791bbe593843ee481184fab1f27f1f4d3abb2d22222f141ceccfa
Got ca3ef965059f3874a208848f38a48191ad113550966f8871e5a74bc0b6f6e2fa
No I don’t want the startup trigger, I need them to record the value at midnight, and only then.
That’s why I had a whole setup with intermediary input_numbers to record those values, and create the template sensors based on these numbers (via a python script)
My hope was that these new trigger based template sensors would only update on the trigger, but would keep their value crossing restarts.
are then only updated at the timed trigger, and keep their value because the input_number hasn’t changed?
I made this python script to not have to do the above for all sensors manually, though it still forces to create all intermediary input_numbers (which I would have liked to prevent with these new trigger based sensors…)
#################################################################################
# Record daystart values for power and usage. To survive restarts, this is done
# with intermediary input_numbers, and an automation calling this Python script
# at midnight
#
# automation:
#
# - alias: Set daystart sensors
# trigger:
# platform: time
# at: '00:00:01'
# action:
# - service: python_script.record_daystart
#################################################################################
switches = 'group.z_wave_switches'
for entity_id in hass.states.get(switches).attributes['entity_id']:
sensor = hass.states.get(entity_id).object_id
input_idPower = 'input_number.{}_power_daystart'.format(sensor);
sensor_idPower = 'sensor.{}_actueel'.format(sensor);
input_idUsage = 'input_number.{}_usage_daystart'.format(sensor);
sensor_idUsage = 'sensor.{}_totaal'.format(sensor);
#################################################################################
# Select Input_number and set value to the corresponding sensor
#################################################################################
# get sensor value
sensor_valuePower = hass.states.get(sensor_idPower).state
sensor_valueUsage = hass.states.get(sensor_idUsage).state
#
# and assign to input_number
hass.services.call(
'input_number',
'set_value',
{'entity_id': input_idPower,
'value': sensor_valuePower}
)
hass.services.call(
'input_number',
'set_value',
{'entity_id': input_idUsage,
'value': sensor_valueUsage}
)
Logger: homeassistant.components.statistics.sensor
Source: components/statistics/sensor.py:159
Integration: statistics (documentation, issues)
First occurred: 19:42:36 (1 occurrences)
Last logged: 19:42:36
sensor.today_temp_bom: parsing error, expected number and received None
Go back to whatever you had before if the new template integration isn’t working. It’ll be getting updates but it won’t get ‘restore state’ until thats implemented everywhere. And I don’t think that’s even being thought about.
Yah, and tag the statistics integration. This try catch’s net is too large
def _add_state_to_queue(self, new_state):
"""Add the state to the queue."""
if new_state.state in [STATE_UNKNOWN, STATE_UNAVAILABLE]:
return
try:
if self.is_binary:
self.states.append(new_state.state)
else:
self.states.append(float(new_state.state))
self.ages.append(new_state.last_updated)
except ValueError:
_LOGGER.error(
"%s: parsing error, expected number and received %s",
self.entity_id,
new_state.state,
)
I assume you just don’t want another integration Tom but the custom average component is much better for that sensor (as you can get the true average for the current day from midnight instead of a 24hr period - also the min temp for the last 24 hrs isn’t necessarily going to be the same as the low temp since midnight etc)
Have you set availability_template in your templates?
Defines a template to get the available state of the component. If the template returns true , the device is available . If the template returns any other value, the device will be unavailable . If availability_template is not configured, the component will always be available .
Yes, thanks.
I have tried all that. Availability_template, default, default(15).
availability_template: >
{% set id = states('sensor.guest_room_sensor_temperature') %}
{% set un = ['unknown','unavailable'] %}
{{id not in un and id is not none}}
Note I don’t get the error on the integration template sensors themselves, but on the min_max integration only.
trying the custom component Average doesn’t help:
2021-04-15 14:58:47 ERROR (MainThread) [custom_components.average.sensor] Unable to find an entity "sensor.guest_room_sensor_calibrated_temperature"
Snapshots always work, but the database can be corrupted if it’s mid write. So it ‘seems’ like the snapshot failed, when in reality it did not. If you separate your database from the snapshot, it never ‘fails’.
Also, moderation title has nothing to do with the ‘core team’. Moderators just manage quarrels on all the home assistant communities.