please help me out. I have a Python script that checks for unavailable entities. I that, I declare a
exclude_conditional_groups = []
and after that, fill it:
if hass.states.get('binary_sensor.dark_outside').state == 'off':
exclude_conditional_groups = ['group.philips_room_motion_sensor_switches','group.philips_buiten_motion_sensor_switches']
or not ofc…
next, there’s a
exclude_groups = ['group.entity_blacklist' ,'group.switches_total_device_power',
'group.switches_total_device_energy','group.lights_inside_total_device_power',
'group.lights_inside_total_device_energy','group.lights_outside_total_device_power',
'group.lights_outside_total_device_energy']
and finally I concatenate these 2 with:
groups_excludes = exclude_groups + exclude_conditional_groups
to do:
# add groups entities to exclude_entities list
for group in groups_excludes:
if group is not None:
for entity_id in hass.states.get(group).attributes['entity_id']:
excludes.append(entity_id)
this works perfectly fine and the entity_id’s get appended alright. However, because one of my integrations currently is in conflict with HA, the groups in the exclude_groups
are not created. this returns an error in the logs for that line
Error executing script: 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 224, in execute
exec(compiled.code, restricted_globals)
File "uun.py", line 75, in <module>
File "/usr/local/lib/python3.9/site-packages/RestrictedPython/Eval.py", line 35, in default_guarded_getitem
return ob[index]
TypeError: 'NoneType' object is not subscriptable
I would have thought the
for group in groups_excludes: # exclude_groups
if group is not None:
would take care of that check, but apparently not.
What should I do to guard that better?
thanks for having a look!
1 post - 1 participant