nielsfaber / scheduler-component

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

log error: extra keys not allowed @ data['porzioni_field'] #322

Closed lorenzomartini1 closed 5 months ago

lorenzomartini1 commented 5 months ago

Expected behavior

Working scheduler

Actual behavior

I'm trying to configure a customized scheduler-card panel. The code is:

type: custom:scheduler-card
include:
  - script.test_eroga_cibo
exclude: []
tags:
  - gatto
show_header_toggle: false
title: Erogazioni di cibo programmate
discover_existing: false
sort_by:
  - state
  - title
display_options:
  primary_info: default
  secondary_info:
    - time
    - days
  icon: action
customize:
  script.test_eroga_cibo:
    icon: mdi:shaker
    exclude_actions:
      - accendi
      - esegui
      - spegni
    actions:
      - service: script.turn_on
        name: Eroga {porzioni_field}
        variables:
          porzioni_field:
            name: dose - 1 porzione = 5g
            unit: ' porzione/i'
            min: 1
            max: 10
            step: 1
        icon: mdi:shaker
time_step: 1

the script.test_eroga_cibo is:

alias: "[Gatto] Eroga cibo"
use_blueprint:
  path: lorenzo/eroga_cibo.yaml
  input:
    pulsante: button.mmgg_fi1_1ffd_pet_food_out
icon: mdi:shaker

and eroga_cibo.yaml is:

blueprint:
  name: Erogazione cibo
  description: >-
    Gestione erogazione di cibo
  domain: script
  input:
    pulsante:
      name: Pulsante da premere
      description: Pulsante associato all'erogazione di una porzione di cibo
      selector:
        entity:
          filter:
            domain: button
fields:
  porzioni_field:
    name: "Porzioni"
    description: "Numero di porzioni da erogare"
    default: 1
    selector:
      number:
        min: 1
        max: 10
        step: 1
        unit_of_measurement: porzioni
mode: queued
max: 10
sequence:
  - variables:
      porzioni: "{{ porzioni_field }}"
  - if:
      - condition: template
        value_template: "{{ porzioni is defined and porzioni > 0 }}"
    then:
      - repeat:
          sequence:
            - service: button.press
              data: {}
              target:
                entity_id: !input pulsante
            - service: notify.lorenzo
              data:
                message: msg
            - delay:
                hours: 0
                minutes: 0
                seconds: 5
                milliseconds: 0
          count: "{{ porzioni|int }}"

when the scheduler executes i got:

Logger: homeassistant.util.logging
Source: util/logging.py:101
First occurred: 14:59:00 (1 occurrences)
Last logged: 14:59:00

Exception in async_timer_finished when dispatching 'scheduler_timer_finished': ('85103e',) 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 283, in async_call_from_config await hass.services.async_call(**params, blocking=blocking, context=context) 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/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['porzioni_field']

how should I solve?

thanks

Steps to Reproduce

[Explain how to see the behaviour]

nielsfaber commented 5 months ago

This is not a bug but configuration error. Your problem is in

actions:
 - service: script.turn_on

The turn_on service does not allow a parameter. you need to replace the service by script.test_eroga_cibo