Closed sobolewskidamian closed 9 months ago
I don't have any color_temp
light at home so I can't test it. But I tried a fix in the v4.1 version. I test the non regression and let you now.
Fixed in v4.1
That problem has not been resolved in v4.1
I think you should add condition "and state.attributes[color_mode] is not None" to "if color_mode in state.attributes" in init.py:321 instead of adding additional condition in init.py:319
Logs:
2024-03-03 23:08:54.369 DEBUG (MainThread) [custom_components.presence_simulation] Got attribute brightness: 51
2024-03-03 23:08:54.369 DEBUG (MainThread) [custom_components.presence_simulation] Got attribute color_mode: color_temp
2024-03-03 23:08:54.370 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 278, in simulate_single_entity
await update_entity(entity_id, state)
File "/config/custom_components/presence_simulation/__init__.py", line 324, in update_entity
await hass.services.async_call("light", "turn_"+state.state, service_data, blocking=False)
File "/usr/src/homeassistant/homeassistant/core.py", line 2245, in async_call
processed_data: dict[str, Any] = handler.schema(service_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/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.12/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.12/site-packages/voluptuous/validators.py", line 351, in _exec
v = func(v)
^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
return schema(data)
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 229, in _run
return self._exec(self._compiled, value, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/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.12/site-packages/voluptuous/validators.py", line 353, in _exec
v = func(path, v)
^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
return schema(data)
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
return base_validate(path, iteritems(data), out)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 433, in validate_mapping
raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: expected int for dictionary value @ data['color_temp']
Could you show me the attributes of your light when it is on please?
DEBUG (MainThread) [custom_components.presence_simulation] State {'entity_id': 'light.kitchen_light', 'state': 'on', 'attributes': {'effect': None, 'color_mode': 'color_temp', 'brightness': 51, 'color_temp_kelvin': None, 'color_temp': None, 'hs_color': None, 'rgb_color': None, 'xy_color': None, 'friendly_name': 'kitchen_light'}, 'last_changed': '2024-02-25T22:59:23.218619+00:00', 'last_updated': '2024-02-25T22:59:23.218619+00:00'}
I tested your last commits in main branch and it seems to be working
Lol. It wasn't the purpose but cool :-) I will make another release then. Thanks for the testing.
When _colormode of light is _colortemp and _colortemp is None, I get exception in _updateentity method. I think that _colormode should be set to _servicedata if it is not None.
Logs: