slashback100 / presence_simulation

Home Assistant Presence Simulation
654 stars 26 forks source link

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' #99

Closed lostcontrol closed 10 months ago

lostcontrol commented 10 months ago

I just noticed the following exception in my logs:

2023-11-09 08:36:31.760 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/presence_simulation/__init__.py", line 301, in simulate_single_entity
await update_entity(entity_id, state)
File "/config/custom_components/presence_simulation/__init__.py", line 341, in update_entity
color_mode = color_mode+"_color"
~~~~~~~~~~^~~~~~~~~
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Running HA 2023.11.1 and the latest version of this project.

ronaldheft commented 10 months ago

Seeing the same error on 2023.11.2. It appears this error breaks the simulation and no light changes occur after.

ronaldheft commented 10 months ago

Seems like there is also an issue with lights that have a brightness value. Any light in my house with a brightness value is not having issues with the simulation.

I have not had a chance to investigate yet, but the error message is:


Logger: homeassistant
Source: core.py:2001
First occurred: November 11, 2023 at 7:25:42 PM (10 occurrences)
Last logged: November 11, 2023 at 8:55:02 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/presence_simulation/__init__.py", line 301, in simulate_single_entity
    await update_entity(entity_id, state)
  File "/config/custom_components/presence_simulation/__init__.py", line 345, in update_entity
    await hass.services.async_call("light", "turn_"+state.state, service_data, blocking=False)
  File "/usr/src/homeassistant/homeassistant/core.py", line 2001, in async_call
    processed_data: dict[str, Any] = handler.schema(service_data)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 232, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 355, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 351, in _exec
    v = func(v)
        ^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
    return schema(data)
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 229, in _run
    return self._exec(self._compiled, value, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 355, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 353, in _exec
    v = func(path, v)
        ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
    return schema(data)
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
    return base_validate(path, iteritems(data), out)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 433, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['brightness']
ronaldheft commented 10 months ago

It appears my None check needed to be further up. I adjusted and have seen the presence simulation working since.

I will update my PR later this evening when I'm back.

ronaldheft commented 10 months ago

Fix should be good to go.

lostcontrol commented 10 months ago

@slashback100 It would be nice to make a new release with this fix. This integration is broken on 2023.11. Thank you.

slashback100 commented 10 months ago

Yes you are right, I just need to find some time to test it before releasing it. I'll do it asap

slashback100 commented 10 months ago

v3.2 released. Sorry for the delay