2021.4: For our advanced users ❤️

with helper you mean eg an input_number? Which would mean that I would have to go back to

automation:

  - alias: Set daystart sensors
    trigger:
      platform: time
      at: '00:00:01'
    action:
      - service: python_script.daystart

which python script in fact does:

      - service: input_number.set_value
        data:
          entity_id: input_number.afzuigkap_zolder_usage_daystart
          value: >
            {{states('sensor.afzuigkap_zolder_totaal')}}

and the template sensors

      afzuigkap_zolder_usage_daystart:
        friendly_name: Afzuigkap zolder usage daystart
        value_template: >
          {{states('input_number.afzuigkap_zolder_usage_daystart')|float}}
        unit_of_measurement: kWh

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}
        )

edited.

I’m getting this error on start up:

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

From this sensor:

- platform: statistics
  name: today_temp_bom
  sampling_size: 150
  entity_id: sensor.hobart_temp
  max_age:
    hours: 24

today_temp_bom comes from the BoM integration and is restored on start up. So something screwy is happening on start-up.

seems like a bug in statistics, just looked at the code and it appears as if None is causing the problem and there’s no check for it.

1 Like

Thanks Petro. Should I open a Core Issue?

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,
            )
1 Like

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)

1 Like

I want the min and max for the templates though.

EDIT: I see it has those attributes. Will try it. Thanks.

thats what I want with the min_max platform, based on templates sensors, but they always error on startup also… min_max doesn't wait for template entities to be ready · Issue #41931 · home-assistant/core · GitHub

@DavidFW1960 don’t you see startup errors in the logs when doing that?

Yeah that works. Thanks.

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 .

That’s scary- coming from a moderator, no less. Are you really saying that snapshots “rarely work”?

OK, it seems the problem with the null value of the AQI attribute was temporary. It’s fine by now:

image

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.

1 Like

@makai maybe I should rephrase my issue: considering template sensors like this:

      guest_room_sensor_calibrated_temperature:
        friendly_name: Guest room calibr temp
        value_template: >
          {{(states('sensor.guest_room_sensor_temperature')|float +
             states('input_number.temp_calibration')|float)|round(2)}}

based on Hue integration sensor temperature (which all lose their states during template reload) how can I guard the above template sensor, so it wont cause havoc in other integrations using it.

As you can see Ive tried the availability sensor, but that wont help, because it merely Weill indicate the entity nit to be available, causing the identical distress in the min_max integration.

Thats why I thought a default value as in the release notes 2021.4 would help, like

   {{((states('sensor.guest_room_sensor_temperature')|default(15))|float +
             states('input_number.temp_calibration')|float)|round(2)}}

but that doesn’t work out either…

click reload templates:

  • first I see the yellow bar of entity is not available,
  • then the entity shows, but only with the second part, the value of the states('input_number.temp_calibration')|float)|round(2),
  • and after that, the correct calibrated sensor finally shows.

Google Assistant Integration Broken?

With the latest 2021.4.4 update, I am having issues with the Google Assistant integration. When I ask Google to turn on or off lights, in the majority of cases, Google responds with “Sorry it looks like Home Assistant is unavailable right now” or “sorry I couldn’t reach Home Assistant”. No other changes have been made to my setup. I also tried reconnecting HA in the Google Home app to no avail.

EDIT: Even reverting to a 4.3 snapshot didn’t resolve this. I verified all settings and also the setup of the Google project as per the official instructions. Everything seems to be in good order. Am I the only one with this issue?

I’m wondering if it is not due to the input_number. What if you remove it?

 {{ (states('sensor.guest_room_sensor_temperature')|default(15))|float }}

In your availability_template do you also check for input_number.temp_calibration availability? because you need to check availability for all entities used in the template

Thanks for the reassurance. I always wait a few days to upgrade to let the major bugs get answered, trusting that I can always restore a prior snapshot if something goes wrong.
I am even more apprehensive when the update thread accumulates over 600 posts in just a week.

If you read the breaking changes, the upgrade typically always goes smoothly. Most of us run betas and find the issues before release (i.e. before this thread).

1 Like