2021.5: Stability, performance, triggers, color modes!

Bild

From these 8 services 5 had been uninstalled and I’m fed up with these deadbeats.

Are they doing you harm? No.

If you think there is a bug, file an issue on github.

Hi all

I get this WARNING/ERROR in the Check Config, but I’m not able to understand how to fix

WARNING:homeassistant.components.template.sensor:The 'entity_id' option near /tmp/config/sensors.yaml:422 is deprecated, please remove it from your configuration
INFO:homeassistant.util.package:Attempting install of fritzconnection==1.4.2
INFO:homeassistant.util.package:Attempting install of pyowm==3.2.0
INFO:homeassistant.util.package:Attempting install of pyatmo==4.2.2
INFO:homeassistant.util.package:Attempting install of shodan==1.25.0
INFO:homeassistant.util.package:Attempting install of psutil==5.8.0
INFO:homeassistant.util.package:Attempting install of aiodns==2.0.0
ERROR:homeassistant.util.package:Unable to install package aiodns==2.0.0: ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
    status = self.run(options, args)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 323, in run
    requirement_set = resolver.resolve(
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 391, in _resolve_one
    dist = abstract_dist.get_pkg_resources_distribution()
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/distributions/wheel.py", line 29, in get_pkg_resources_distribution
    with ZipFile(self.req.local_file_path, allowZip64=True) as z:
  File "/usr/local/lib/python3.8/zipfile.py", line 1269, in __init__
    self._RealGetContents()
  File "/usr/local/lib/python3.8/zipfile.py", line 1336, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
WARNING: You are using pip version 20.2.4; however, version 21.1.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
WARNING:homeassistant.components.uptime.sensor:The 'unit_of_measurement' option is deprecated, please remove it from your configuration
e[01;37mFailed confige[0m
  e[01;31mGeneral Errors:e[0m e[31me[31m
    - Platform error binary_sensor.dpc - No module named 'dateutil'
    - Platform error sensor.dnsip - Requirements for dnsip not found: ['aiodns==2.0.0'].
e[0m
e[01;37mSuccessful config (partial)e[0m

In detail, the first warning
WARNING:homeassistant.components.template.sensor:The 'entity_id' option near /tmp/config/sensors.yaml:422 is deprecated, please remove it from your configuration

This is the config in sensors.yaml

      last_alexa:
        entity_id:
         - media_player.alexa_2
         - media_player.echo_2
         - media_player.echo_bianco
         - media_player.echo_input
         - media_player.echo_input_letto
         - media_player.vittorio_s_alexa_apps_2
        value_template: >
          {{ states.media_player | selectattr('attributes.last_called','eq',True) | map(attribute='entity_id') | first }}

Then, I have this error

ERROR:homeassistant.util.package:Unable to install package aiodns==2.0.0: ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
    status = self.run(options, args)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 323, in run
    requirement_set = resolver.resolve(
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py", line 391, in _resolve_one
    dist = abstract_dist.get_pkg_resources_distribution()
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/distributions/wheel.py", line 29, in get_pkg_resources_distribution
    with ZipFile(self.req.local_file_path, allowZip64=True) as z:
  File "/usr/local/lib/python3.8/zipfile.py", line 1269, in __init__
    self._RealGetContents()
  File "/usr/local/lib/python3.8/zipfile.py", line 1336, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

But I don’t understand what is about…

The last two are

WARNING: You are using pip version 20.2.4; however, version 21.1.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.

I have HA installed in a Proxmox VM via the whiskerz007 script

How can I update Python

and last

WARNING:homeassistant.components.uptime.sensor:The 'unit_of_measurement' option is deprecated, please remove it from your configuration
e[01;37mFailed confige[0m
  e[01;31mGeneral Errors:e[0m e[31me[31m
    - Platform error binary_sensor.dpc - No module named 'dateutil'
    - Platform error sensor.dnsip - Requirements for dnsip not found: ['aiodns==2.0.0'].
e[0m
e[01;37mSuccessful config (partial)e[0m

Any help?

Thanks!

It‘s completely irrelevant if they are doing me a harm or not, that‘s not a helpful answer. I want to understand.

So remove the entities if they weren’t already done when the add-ons were uninstalled. They will simply be the add-on version tracking sensors.

Hi, it looks like 2021.5.2 Docker-Core broke the Tibber integration. If I revert back to 2021.5.1 it works ok.
This is the error message I get:

2021-05-12 11:20:07 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform tibber
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 558, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 580, in add_to_platform_finish
await self.async_added_to_hass()
File "/usr/src/homeassistant/homeassistant/components/tibber/sensor.py", line 181, in async_added_to_hass
await self._tibber_home.rt_subscribe(self.hass.loop, self._async_callback)
File "/usr/local/lib/python3.8/site-packages/tibber/__init__.py", line 622, in rt_subscribe
await self._tibber_control.rt_connect(loop)
File "/usr/local/lib/python3.8/site-packages/tibber/__init__.py", line 70, in rt_connect
self.sub_manager = SubscriptionManager(
TypeError: __init__() takes 3 positional arguments but 4 were given
2021-05-12 11:20:07 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up tibber platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 239, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 558, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 580, in add_to_platform_finish
await self.async_added_to_hass()
File "/usr/src/homeassistant/homeassistant/components/tibber/sensor.py", line 181, in async_added_to_hass
await self._tibber_home.rt_subscribe(self.hass.loop, self._async_callback)
File "/usr/local/lib/python3.8/site-packages/tibber/__init__.py", line 622, in rt_subscribe
await self._tibber_control.rt_connect(loop)
File "/usr/local/lib/python3.8/site-packages/tibber/__init__.py", line 70, in rt_connect
self.sub_manager = SubscriptionManager(
TypeError: __init__() takes 3 positional arguments but 4 were given
7 Likes

I’ve this issue here, not knowing if this belongs to the recent update?

Logger: pyShelly
Source: helpers/entity.py:474
First occurred: 11:45:01 (1624 occurrences)
Last logged: 11:48:44

Error receiving CoAP UDP, 'NoneType' object has no attribute 'add_job', Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/pyShelly/coap.py", line 187, in _loop self._root.update_block(device_id, device_type, File "/usr/local/lib/python3.8/site-packages/pyShelly/__init__.py", line 307, in update_block block.update_coap(data, ipaddr) File "/usr/local/lib/python3.8/site-packages/pyShelly/block.py", line 102, in update_coap dev.raise_updated() File "/usr/local/lib/python3.8/site-packages/pyShelly/base.py", line 45, in raise_updated callback(self) File "/config/custom_components/shelly/device.py", line 58, in _updated self._update_ha_state() File "/config/custom_components/shelly/device.py", line 51, in _update_ha_state self.schedule_update_ha_state(True) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in schedule_update_ha_state self.hass.add_job(self.async_update_ha_state(force_refresh)) # type: ignore AttributeError: 'NoneType' object has no attribute 'add_job'
Error receiving CoAP UDP, 'NoneType' object has no attribute 'add_job', Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/pyShelly/coap.py", line 187, in _loop self._root.update_block(device_id, device_type, File "/usr/local/lib/python3.8/site-packages/pyShelly/__init__.py", line 307, in update_block block.update_coap(data, ipaddr) File "/usr/local/lib/python3.8/site-packages/pyShelly/block.py", line 101, in update_coap dev.update_coap(payload) File "/usr/local/lib/python3.8/site-packages/pyShelly/light.py", line 280, in update_coap self._update(SRC_COAP, new_state, values) File "/usr/local/lib/python3.8/site-packages/pyShelly/device.py", line 98, in _update self.raise_updated() File "/usr/local/lib/python3.8/site-packages/pyShelly/base.py", line 45, in raise_updated callback(self) File "/config/custom_components/shelly/device.py", line 58, in _updated self._update_ha_state() File "/config/custom_components/shelly/device.py", line 51, in _update_ha_state self.schedule_update_ha_state(True) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in schedule_update_ha_state self.hass.add_job(self.async_update_ha_state(force_refresh)) # type: ignore AttributeError: 'NoneType' object has no attribute 'add_job'
Error receiving CoAP UDP, 'NoneType' object has no attribute 'add_job', Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/pyShelly/coap.py", line 187, in _loop self._root.update_block(device_id, device_type, File "/usr/local/lib/python3.8/site-packages/pyShelly/__init__.py", line 307, in update_block block.update_coap(data, ipaddr) File "/usr/local/lib/python3.8/site-packages/pyShelly/block.py", line 101, in update_coap dev.update_coap(payload) File "/usr/local/lib/python3.8/site-packages/pyShelly/switch.py", line 79, in update_coap self.__update(state, event_cnt, last_event, SRC_COAP) File "/usr/local/lib/python3.8/site-packages/pyShelly/switch.py", line 61, in __update self._update(src, state, {'last_event' : self.last_event, File "/usr/local/lib/python3.8/site-packages/pyShelly/device.py", line 98, in _update self.raise_updated() File "/usr/local/lib/python3.8/site-packages/pyShelly/base.py", line 45, in raise_updated callback(self) File "/config/custom_components/shelly/device.py", line 58, in _updated self._update_ha_state() File "/config/custom_components/shelly/device.py", line 51, in _update_ha_state self.schedule_update_ha_state(True) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in schedule_update_ha_state self.hass.add_job(self.async_update_ha_state(force_refresh)) # type: ignore AttributeError: 'NoneType' object has no attribute 'add_job'
Error receiving CoAP UDP, 'NoneType' object has no attribute 'add_job', Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/pyShelly/coap.py", line 187, in _loop self._root.update_block(device_id, device_type, File "/usr/local/lib/python3.8/site-packages/pyShelly/__init__.py", line 307, in update_block block.update_coap(data, ipaddr) File "/usr/local/lib/python3.8/site-packages/pyShelly/block.py", line 101, in update_coap dev.update_coap(payload) File "/usr/local/lib/python3.8/site-packages/pyShelly/dimmer.py", line 45, in update_coap self._update(SRC_COAP,new_state, values) File "/usr/local/lib/python3.8/site-packages/pyShelly/device.py", line 98, in _update self.raise_updated() File "/usr/local/lib/python3.8/site-packages/pyShelly/base.py", line 45, in raise_updated callback(self) File "/config/custom_components/shelly/device.py", line 58, in _updated self._update_ha_state() File "/config/custom_components/shelly/device.py", line 51, in _update_ha_state self.schedule_update_ha_state(True) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in schedule_update_ha_state self.hass.add_job(self.async_update_ha_state(force_refresh)) # type: ignore AttributeError: 'NoneType' object has no attribute 'add_job'
Error update device status: B8C512 SHSW-1, 'NoneType' object has no attribute 'add_job', Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/pyShelly/block.py", line 253, in _update_status_info dev.raise_updated(force_update_devices) File "/usr/local/lib/python3.8/site-packages/pyShelly/base.py", line 45, in raise_updated callback(self) File "/config/custom_components/shelly/device.py", line 58, in _updated self._update_ha_state() File "/config/custom_components/shelly/device.py", line 51, in _update_ha_state self.schedule_update_ha_state(True) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in schedule_update_ha_state self.hass.add_job(self.async_update_ha_state(force_refresh)) # type: ignore AttributeError: 'NoneType' object has no attribute 'add_job'
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pyShelly/coap.py", line 187, in _loop
    self._root.update_block(device_id, device_type,
  File "/usr/local/lib/python3.8/site-packages/pyShelly/__init__.py", line 307, in update_block
    block.update_coap(data, ipaddr)
  File "/usr/local/lib/python3.8/site-packages/pyShelly/block.py", line 102, in update_coap
    dev.raise_updated()
  File "/usr/local/lib/python3.8/site-packages/pyShelly/base.py", line 45, in raise_updated
    callback(self)
  File "/config/custom_components/shelly/device.py", line 58, in _updated
    self._update_ha_state()
  File "/config/custom_components/shelly/device.py", line 51, in _update_ha_state
    self.schedule_update_ha_state(True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in schedule_update_ha_state
    self.hass.add_job(self.async_update_ha_state(force_refresh))  # type: ignore
AttributeError: 'NoneType' object has no attribute 'add_job'

It belongs on the issue tracker for that custom integration

Brakes the sonoff offline integration stuck in safe mode

A short rant. And it comes because this was a problem from 2019 to 2020 where one simple bug made time depending automations (typically automations that only activates during night time, something most of us have).

TOD is goofed up again. Again Time Of Day does not work when you restart home assistant. Night becomes day if you restart HA at night which is 95% of the case for most I am sure. This bug has been raised in different incarnations last year.

This is so frustrating. You can say this only happens when you restart HA. But we all know that just upgrading HA and some integrations like HACS, and Alexa Media Player means at least one restart every third day on average. Too often to have any automations rely on a broken TOD integration.

Please priotize this bug. I put a reference to the previous bug on the github item so hopefully it will be easier to fix this time.

If this breaks so often, why don’t you just use a template sensor instead? I also want to be clear: I’m offering a work around to avoid TOD. Yes it should work normally. But personally, if I had an integration that kept breaking I would try to find something more stable. And a template entity gives you everything you need:

template:
- binary_sensor:
  - name: Night Time
    unique_id: night_time
    state: >
      {{ not '06:30' <= as_timestamp(now()) | custom_timestamp('%H:%M') <= '23:00' }}

Idea is good

But I think you did not try this one

Invalid config for [template]: invalid template (TemplateAssertionError: No filter named ‘custom_timestamp’.) for dictionary value @ data[‘binary_sensor’][0][‘state’]. Got "{{ not ‘06:30’ <= as_timestamp(now()) | custom_timestamp(’%H:%M’) <= ‘23:00’ }}

More than one problem with it

This is the right syntax

{{ not '06:30' < as_timestamp(now()) | timestamp_custom('%H:%M', True) }}

But I think this is only half the way. The sensor needs to be on between a time in the evening and a time in the morning. A typical usecase is turn on the light in the hallway DIMMED when there is motion between 23:00 and 05:00.

So I have something similar to this in my config. But was thinking the latest template changes actually provide us with a more efficient way to implement stuff like this:

template:
  - trigger:
      - platform: time
        at: '06:30:00'
      - platform: time
        at: '23:00:00'
    binary_sensor:
      - name: Night Time
        unique_id: night_time
        state: "{{ trigger.now.hour > 22 }}"

Now my sensor is no longer evaluated every minute since it doesn’t include now(). Was thinking of refactoring a lot of my own stuff to reduce reliance on now() when I could thanks to these new triggers.

EDIT: Set condition to greater then 22 because figured there was a tiny chance it would fire at like 22:59:59.9999 or something. Like a negligible amount of time before 23:00:00.

netatmo not work again

Yes, I used the wrong call. This should work.

template:
- binary_sensor:
  - name: Night Time
    unique_id: night_time
    state: >
      {{ not '06:30' <= as_timestamp(now()) | timestamp_custom('%H:%M') <= '23:00' }}

Anwyas to explain the code…

'06:30' <= as_timestamp(now()) | timestamp_custom('%H:%M') <= '23:00' verifies the time is between 630 and 2300.

the not in front of that chooses the opposite time… I.e. night.

1 Like

@CentralCommand how does that sensor survive a HA restart? I would think it only updates at the two given times and end up wrong after a restart.

And as a follow up to brilliant @petro.

Here is a working sensor based on your suggestion.

- binary_sensor:
  - name: Night Time Sensor
    unique_id: night_time_sensor
    state: >
      {{ ( '23:00' <= as_timestamp(now()) | timestamp_custom('%H:%M', True ) ) or
         ( '06:30' >= as_timestamp(now()) | timestamp_custom('%H:%M', True ) ) }}

Edit: Posted in paralel with @petros latest. And his is even more elegant

Lol great question. I’m still hoping to get an answer to that as well

Since its still a template sensor at the end of the day I assume it restores its state after restart. But it would be great to get confirmation. Haven’t been able to try them out yet myself since I would need to do a lot of refactoring to move things out of packages.

It won’t without trigger, but you could add trigger homeassistant.start, and it will evaluate at start

    - platform: homeassistant
      # Event can also be 'shutdown'
      event: start

I see. I wouldn’t have access to trigger.now in that case (since that’s specific to the time triggers). So if I specify my own triggers then it won’t evaluate every minute but I still have to use the now() based template like petro showed. So in the end it would be like this:

template:
  - trigger:
      - platform: time
        at: '06:30:00'
      - platform: time
        at: '23:00:00'
      - platform: homeassistant
        event: start
    binary_sensor:
      - name: Night Time
        unique_id: night_time
        state: >
          {{ ( '23:00' <= as_timestamp(now()) | timestamp_custom('%H:%M', True ) ) or
             ( '06:30' >= as_timestamp(now()) | timestamp_custom('%H:%M', True ) ) }}

Starting to look like a lot of YAML for this one sensor. Plus I hate that I have to put 06:30 and 23:00 in there twice. If they don’t restore and I have to put in the homeassistant.start trigger then I kind of wonder if its really worth it. Probably doesn’t actually add much overhead to run it every minute.