scheduler-component icon indicating copy to clipboard operation
scheduler-component copied to clipboard

Errors with Template Fan

Open hvorragend opened this issue 3 years ago • 2 comments

Checklist

  • [ ] scheduler-component 3.2.10
  • [ ] scheduler-card 2.3.5
  • [ ] Home Assistant 2022.8.4
  • [ ] Supervisor 2022.08.3
  • [ ] Operating System 8.4
  • [ ] Frontend 20220802.0 - latest

Expected behavior

No errors in core log.

Actual behavior

Each time I restart the core, two errors occur in my core log file. They just occur if the scheduler-switch is activated. There are no errors when this scheduler-switch is deactivated.

And it doesn't matter if I use set_preset_mode or set_percentage inside the scheduler.

I've ruled out a lot of potential bugs by now and I would imagine the bug is inside the scheduler-component.

Can you help me? Thank you very much.

Errors:

Logger: homeassistant.helpers.script.luftungsanlage
Source: helpers/script.py:405 
First occurred: 17:52:39 (1 occurrences) 
Last logged: 17:52:39

Lüftungsanlage: Error executing script. Service not found for call_service at pos 1: Unable to find service input_select.select_option
Logger: homeassistant.core
Source: [core.py:1660](http://core.py:1660/) 
First occurred: 17:52:39 (1 occurrences) 
Last logged: 17:52:39

Error executing service: <ServiceCall fan.set_preset_mode (c:01XAXYGXMHXRCXN1XWCXSKX6RX): preset_mode=Feuchteschutz, entity_id=['fan.kwl_fan']>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1731, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 676, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 930, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 713, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/template/fan.py", line 298, in async_set_preset_mode
    await self.async_run_script(
  File "/usr/src/homeassistant/homeassistant/helpers/template_entity.py", line 407, in async_run_script
    return await script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1513, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 405, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 449, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 472, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 447, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 680, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1660, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service input_select.select_option

My fan template: fan.kwl_fan

- platform: template
  fans:
    kwl_fan:
      friendly_name: "Lüftungsanlage"
      unique_id: my_kwl_fan
      value_template: "{{ states('switch.lueftungsanlage') }}"
      percentage_template: >-
        {% if states('input_select.kwl_fan_mode') == 'Feuchteschutz' %}
          25
        {% elif states('input_select.kwl_fan_mode') == 'Reduziert' %}
          50
        {% elif states('input_select.kwl_fan_mode') == 'Normal' %}
          75
        {% elif states('input_select.kwl_fan_mode') == 'Intensiv' %}
          100
        {% else %}
          25
        {% endif %}
      preset_mode_template: "{{ states('input_select.kwl_fan_mode') }}"
      turn_on:
        service: switch.turn_on
        target:
          entity_id: switch.lueftungsanlage
      turn_off:
        service: switch.turn_off
        target:
          entity_id: switch.lueftungsanlage
      set_percentage:
        service: input_select.select_option
        target:
          entity_id: input_select.kwl_fan_mode
        data:
          option: >-
            {% if percentage > 90 %}
              Intensiv
            {% elif percentage > 60 %}
              Normal
            {% elif percentage > 30 %}
              Reduziert
            {% elif percentage > 0 %}
              Feuchteschutz
            {% else %}
              Feuchteschutz
            {% endif %}
      set_preset_mode:
        service: input_select.select_option
        target:
          entity_id: input_select.kwl_fan_mode
        data:
          option: "{{ preset_mode }}"
      speed_count: 4
      preset_modes:
        - "Feuchteschutz"
        - "Reduziert"
        - "Normal"
        - "Intensiv"

input_select.kwl_fan_mode:

kwl_fan_mode:
  name: Ventilatorbetrieb
  icon: mdi:fan
  options:
    - "Off"
    - "Feuchteschutz"
    - "Reduziert"
    - "Normal"
    - "Intensiv"

switch.schedule_kwl:

weekdays:
  - daily
timeslots:
  - 00:00:00 - 01:00:00
  - 01:00:00 - 09:05:00
  - 09:05:00 - 15:00:00
  - 15:00:00 - 21:00:00
  - 21:00:00 - 00:00:00
entities:
  - fan.kwl_fan
actions:
  - service: fan.set_preset_mode
    data:
      preset_mode: Normal
  - service: fan.set_preset_mode
    data:
      preset_mode: Normal
  - service: fan.set_preset_mode
    data:
      preset_mode: Feuchteschutz
  - service: fan.set_preset_mode
    data:
      preset_mode: Feuchteschutz
  - service: fan.set_preset_mode
    data:
      preset_mode: Normal
current_slot: 3
next_slot: 4
next_trigger: '2022-08-13T21:00:00+02:00'
tags: []
icon: mdi:calendar-clock
friendly_name: KWL

Steps to Reproduce

[Explain how to see the behaviour]

hvorragend avatar Aug 13 '22 16:08 hvorragend

The log suggests you have made a schedule for an input_select. Apparently the schedule is triggered on startup (probably due to an active timeslot) but the input_select integration is not loaded yet. I don't see any issues regarding the fans, at least from the logs you shared.

I would like to tackle the issue which you experience, but I don't know how to. The problem is that the loading (and order of loading) integrations in HA is out of my control. There are some provisions in scheduler that postpone the triggering of the actions until HA is 'ready', but apparently this is not the case for you.

The log errors are quite harmless, but the action for the input_select is probably not triggered on restarting of HA. I cannot judge if this is a problem for your setup or not.

nielsfaber avatar Aug 13 '22 16:08 nielsfaber

Thank you for your feedback. I can live with it. :-)

hvorragend avatar Aug 13 '22 17:08 hvorragend

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

github-actions[bot] avatar Sep 13 '22 01:09 github-actions[bot]