Door/Window Group (Count) - stopped working 0.104.3 > 0.107.5

Been using the manual mqtt alarm control panel platform happily for nearly going on a year now.

Screenshot_3

Last week I update Home Assistant from 0.104.5 to the fastest 0.107.5 which broke the code that counts door and windows that are open.

Count

I read on the release notes for 0.105 that view and control features of Groups was removed 0.107 but the code I use doesn’t use this and can’t seem to figure out why it won’t load since 0.107

This is my alarm code

#################################################################
#                                                               #
#                    Packages/Alarm System                      #
#                                                               #
#################################################################

#################################################################
#                                                               #
#                          Customize                            #
#                                                               #
#################################################################

homeassistant:
  customize:
    alarm_control_panel.ha_alarm:
      icon: mdi:shield-home
    binary_sensor.door_window_sensor_hiddenb9:
      friendly_name: Sliding Door
      device_class: door
    binary_sensor.door_window_sensor_hidden16:
      friendly_name: Front Door
      device_class: door
    binary_sensor.door_window_sensor_hiddena4:
      friendly_name: Laundry Door
      device_class: door
    binary_sensor.door_window_sensor_hidden13:
      friendly_name: Garage Door
      device_class: door
    binary_sensor.door_window_sensor_hiddenc0:
      friendly_name: Bathroom Window
      device_class: window
    binary_sensor.motion_sensor_hidden1f:
      friendly_name: Porch Motion Sensor
    binary_sensor.motion_sensor_hiddene9:
      friendly_name: Lawn Motion Sensor
    binary_sensor.motion_sensor_hidden3e:
      friendly_name: Woodpile Motion Sensor
    binary_sensor.motion_sensor_hidden8f:
      friendly_name: Garage Motion Sensor
#    binary_sensor.smoke_sensor_hiddenba:
#     friendly_name: Upstairs Smoke Detector
#     device_class: smoke

#################################################################
#                                                               #
#                           Group                               #
#                                                               #
#################################################################

group:
  security:
    name: Security
    icon: mdi:security-home
    view: yes
    entities:
      - group.alarms
      - group.doors
      - group.windows
      - group.motion
      
  alarms:
    name: Alarms
    icon: mdi:security
    view: no
    entities:
      - alarm_control_panel.ha_alarm
      
  motion:
    name: Motion
    icon: mdi:walk
    view: no
    entities:
      - binary_sensor.motion_sensor_hidden8f
      - binary_sensor.motion_sensor_hiddene9
      - binary_sensor.motion_sensor_hidden3e
      - binary_sensor.motion_sensor_hidden8f
      
  doors:
    name: Doors
    icon: mdi:door
    view: no
    entities:
      - binary_sensor.door_window_sensor_hiddenb9
      - binary_sensor.door_window_sensor_hidden16
      - binary_sensor.door_window_sensor_hiddena4
      - binary_sensor.door_window_sensor_hidden13
      
  windows:
    name: Windows
    icon: mdi:window
    view: no
    entities:
      - binary_sensor.door_window_sensor_hiddenc0
      
#################################################################
#                                                               #
#                     MQTT Control Panel                        #
#                                                               #
#################################################################

alarm_control_panel:
  - platform: manual_mqtt
    code: 1402
    state_topic: home/alarm
    command_topic: home/alarm/set
    code_arm_required: false
    pending_time: 30
    delay_time: 10
    trigger_time: 300
    disarmed:
      trigger_time: 0
    armed_home:
      pending_time: 15
      delay_time: 5
    armed_away:
      pending_time: 30
      delay_time: 5
    triggered:
      pending_time: 10
    
#################################################################
#                                                               #
#                      Template Sensors                         #
#                                                               #
#################################################################

sensor:
  - platform: template
    sensors:
      door_count:
        value_template: >-
           {{ states | selectattr('entity_id','in',state_attr('group.doors','entity_id')) | selectattr('state','eq','on') | list | count | int}}
      window_count:
        value_template: >-
           {{ states | selectattr('entity_id','in',state_attr('group.windows','entity_id')) | selectattr('state','eq','on') | list | count | int}}
           
#################################################################
#                                                               #
#                       Binary Sensors                          #
#                                                               #
#################################################################

### For Lovelace UI ###

#################################################################
#                                                               #
#                       Booleans Sensors                        #
#                                                               #
#################################################################
input_boolean:
  garage_armed:
    name: Arm garage
    initial: off
  backdoors_armed:
    name: Arm backdoors
    initial: off

####################################################
#                                                  #
#             Binary Sensor - Template             #
#                                                  #
####################################################
# This area sets the icon type for each group open/closed or missing

binary_sensor:
  - platform: template
    sensors:
## Door Sensors
      doors:
        friendly_name: Doors
        device_class: door
        entity_id: group.doors
        value_template: "{{ is_state('group.doors', 'on') }}"
        icon_template: >-
          {% if is_state('group.doors', 'on') %}
            fas:door-open
          {% elif is_state('group.doors', 'off') %}
            fas:door-closed         
          {% else %}
            mdi:alert
          {% endif %}
## Window Sensors
      windows:
        friendly_name: Windows
        device_class: window
        entity_id: group.windows
        value_template: "{{ is_state('group.windows', 'on') }}"
        icon_template: >-
          {% if is_state('group.windows', 'on') %}
            mdi:window-open
          {% elif is_state('group.windows', 'off') %}
            mdi:window-closed       
          {% else %}
            mdi:alert
          {% endif %}
## Alarm Panel
      alarm:
        friendly_name: Alarm
        entity_id: alarm_control_panel.ha_alarm
        value_template: >-
          {% if is_state('alarm_control_panel.ha_alarm', 'armed_home') %}
            on
          {% elif is_state('alarm_control_panel.ha_alarm', 'armed_away') %}
            on
          {% elif is_state('alarm_control_panel.ha_alarm', 'pending') %}
            on
          {% elif is_state('alarm_control_panel.ha_alarm', 'triggered') %}
            on
          {% else %}
            off
          {% endif %}
        icon_template: >-
          {% if is_state('alarm_control_panel.ha_alarm', 'armed_home') %}
            mdi:shield-home
          {% elif is_state('alarm_control_panel.ha_alarm', 'armed_away') %}
            mdi:shield-lock
          {% elif is_state('alarm_control_panel.ha_alarm', 'pending') %}
            mdi:security
          {% elif is_state('alarm_control_panel.ha_alarm', 'triggered') %}
            mdi:shield-close
          {% elif is_state('alarm_control_panel.ha_alarm', 'disarmed') %}
            mdi:shield-home
          {% else %}
            mdi:alert
          {% endif %}

Remove this from your groups:

view: no/yes

It is an option for the old states UI that has been removed and is causing your groups to fail. See: 0.107: Multiple Lovelace Dashboards, adds helpers, new media player card

Groups - Groups are NOT being removed, but the configuration options, services, and service options related to the (previously deprecated and now removed) States UI are now removed in this release. This includes:

  • The view and control configuration options for a group.
  • The group.set_visibility service call
  • The control , visible , view options on the group.set service call
1 Like

Ah I see them.

I removed them and restarted, but nothing changed.

Screenshot_4

There is entry in the log from 2 hours ago which relates to door and window sensor count fail. I did do a image restore which went back to 0.104 from 0.107 and then I updated to 0.107 yesterday which corrupted the home-assistant_v2.db which I deleted and allowed it to recreate itself.

2020-03-22 13:16:03 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.door_count fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/template/sensor.py", line 224, in async_update
    self._state = self._template.async_render()
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 221, in async_render
    return compiled.render(kwargs).strip()
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 1016, in do_list
    return list(value)
  File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 1323, in select_or_reject
    for item in seq:
  File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 1324, in select_or_reject
    if func(item):
  File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 1317, in <lambda>
    return seq, lambda item: modfunc(func(transfunc(item)))
  File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 1312, in func
    return context.environment.call_test(name, item, args, kwargs)
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 520, in call_test
    return func(value, *(args or ()), **(kwargs or {}))
  File "/usr/local/lib/python3.7/site-packages/jinja2/tests.py", line 174, in test_in
    return value in seq
TypeError: argument of type 'NoneType' is not iterable
2020-03-22 13:16:03 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.window_count fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/template/sensor.py", line 224, in async_update
    self._state = self._template.async_render()
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 221, in async_render
    return compiled.render(kwargs).strip()
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 1016, in do_list
    return list(value)
  File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 1323, in select_or_reject
    for item in seq:
  File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 1324, in select_or_reject
    if func(item):
  File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 1317, in <lambda>
    return seq, lambda item: modfunc(func(transfunc(item)))
  File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 1312, in func
    return context.environment.call_test(name, item, args, kwargs)
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 520, in call_test
    return func(value, *(args or ()), **(kwargs or {}))
  File "/usr/local/lib/python3.7/site-packages/jinja2/tests.py", line 174, in test_in
    return value in seq
TypeError: argument of type 'NoneType' is not iterable

Have you checked the dev tools states menu to see if those groups exist?

If not, you may still be using depreciated group options or services elsewhere.