nielsfaber / scheduler-component

Custom component for HA that enables the creation of scheduler entities
GNU General Public License v3.0
622 stars 40 forks source link

customize actions mqtt.publish - extra keys not allowed #281

Closed PierreMacherel closed 12 months ago

PierreMacherel commented 1 year ago

It is currently not possible to run custom actions calling the service mqtt.publish.

Checklist

Expected behavior

Calling the mqtt.publish service fail because the scheduler component add an entity_id attribute that mqtt.publish do not expect. I use the HA mqtt integration. An option would be to disable the entity_id attribute insertion in customized action yaml config card.

Actual behavior

When the mqtt.publish service is called by the scheduler, an error is raised, and the service is not called

Error:

Exception in async_timer_finished when dispatching 'scheduler_timer_finished': ('5d5fa7',) Traceback (most recent call last): File "/config/custom_components/scheduler/switch.py", line 275, in async_timer_finished await self._action_handler.async_queue_actions( File "/config/custom_components/scheduler/actions.py", line 261, in async_queue_actions await queue.async_start() File "/config/custom_components/scheduler/actions.py", line 383, in async_start await self.async_process_queue() File "/config/custom_components/scheduler/actions.py", line 525, in async_process_queue await async_call_from_config( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 282, in async_call_from_config await hass.services.async_call(**params, blocking=blocking, context=context) File "/usr/src/homeassistant/homeassistant/core.py", line 1926, 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/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['entity_id'] 

Steps to Reproduce

Card config

  - type: custom:scheduler-card
    show_add_button: true
    include:
    - climate.hvac_living_room
    customize:
      climate.hvac_living_room:
        actions:
          - service: mqtt.publish
            name: custom action
            service_data:
              topic: a_topic
              payload: a string

Add an entry (action or schema) calling the custom action defined above. it will trigger an error in HA logs when called

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days