Input_boolean service breaking automations

Hey everybody,

I am going a bit insane with several of my automations randomly breaking and not executing correctly. I now realized, that apparently the service input_boolean.turn_off somehow messes with my automations and I have no clue why.

For example I have this automation for when I leave the house:

alias: gehen
description: ""
trigger:
  - platform: state
    entity_id:
      - input_select.gregor
    from: Zuhause
    to: Unterwegs
condition: []
action:
  - if:
      - condition: state
        entity_id: input_select.katze
        state: Zuhause
      - condition: state
        entity_id: sun.sun
        state: below_horizon
      - condition: time
        before: "01:00:00"
        after: "12:00:00"
    then:
      - service: scene.turn_on
        target:
          entity_id: scene.katze_zuhause
        metadata: {}
    else:
      - service: scene.turn_on
        target:
          entity_id: scene.licht_aus
        metadata: {}
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.wz_temp
  - service: climate.set_preset_mode
    data:
      preset_mode: away
    target:
      entity_id:
        - climate.heizung_wohnzimmer
        - climate.thermostat_bad
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.kaffeemaschine
  - service: media_player.turn_off
    data: {}
    target:
      entity_id:
        - media_player.denon_avr_x1700h
        - media_player.sony_xr_55a80j
  - if:
      - condition: state
        entity_id: switch.thinkpad_480s
        state: "on"
    then:
      - service: script.laptop_aus_kein_download
        data: {}
  - if:
      - condition: state
        entity_id: media_player.vlc_telnet
        state: playing
    then:
      - service: media_player.media_stop
        data: {}
        target:
          entity_id: media_player.vlc_telnet
  - delay:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
  - if:
      - condition: and
        conditions:
          - condition: state
            entity_id: input_select.gregor
            state: Unterwegs
            for:
              hours: 0
              minutes: 0
              seconds: 0
          - condition: time
            after: "06:00:00"
            before: "20:00:00"
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
              - sat
              - sun
          - condition: state
            entity_id: timer.staubsauger_pause
            state: idle
    then:
      - service: vacuum.start
        data: {}
        target:
          entity_id: vacuum.robot
      - delay:
          hours: 0
          minutes: 0
          seconds: 5
          milliseconds: 0
      - service: vacuum.set_fan_speed
        data:
          fan_speed: Strong
        target:
          entity_id: vacuum.robot
      - delay:
          hours: 0
          minutes: 15
          seconds: 0
          milliseconds: 0
      - service: vacuum.return_to_base
        data: {}
        target:
          entity_id: vacuum.robot
      - service: timer.start
        data:
          duration: 0
        target:
          entity_id: timer.staubsauger_pause
mode: single

If I have it like this the lights turn off (first action in the automation) but nothing else happens and I get this error in the log:

Logger: homeassistant.components.automation.cat_home
Source: components/automation/__init__.py:655
Integration: Automatisierung (documentation, issues)
First occurred: 15:13:42 (2 occurrences)
Last logged: 15:14:02

While executing automation automation.cat_home
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/jsons/_load_impl.py", line 150, in loads
    obj = json.loads(str_, **jdkwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
               ^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 16 (char 15)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 655, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1578, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 420, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 470, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 493, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 957, in _async_if_step
    await self._async_run_script(if_data["if_else"])
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1069, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1578, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 420, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 470, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 493, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/scene/__init__.py", line 114, in _async_activate
    await self.async_activate(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/scene.py", line 375, in async_activate
    await async_reproduce_state(
  File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 67, in async_reproduce_state
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 61, in worker
    await platform.async_reproduce_states(
  File "/usr/src/homeassistant/homeassistant/components/switch/reproduce_state.py", line 67, in async_reproduce_states
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/components/switch/reproduce_state.py", line 54, in _async_reproduce_state
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/tapo/switch.py", line 78, in async_turn_off
    (await self.coordinator.device.off()).get_or_raise()
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/api/plug_device.py", line 35, in off
    return await self._api.set_device_info(SetPlugInfoParams(False))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/api/tapo_client.py", line 122, in set_device_info
    return await self._set_device_info(dataclass_encode_json(device_info))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/api/tapo_client.py", line 223, in _set_device_info
    response = await self._protocol.send_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/klap_protocol.py", line 48, in send_request
    response = await self._send_request(request, retry)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/klap_protocol.py", line 88, in _send_request
    decrypted_response = jsons.loads(
                         ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jsons/_load_impl.py", line 152, in loads
    raise DecodeError('Could not load a dict; the given string is not '
jsons.exceptions.DecodeError: Could not load a dict; the given string is not valid JSON.: line 1 column 16 (char 15)

Though if I deactivate this part of the automation:

  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.wz_temp

Everything executes fine and I get no error in the logs. It also does not matter where in the automation I put the input_boolean.turn_off part, nothing works once it’s somewhere in there.
If I execute the service as it is outside of the automation it works just fine, so it does not seem to be an issue with the service as such.

I can’t exactly say when this started, but the automations used to run just fine and mybe two months ago I starte to see this behavior. Can anyone make any sense of this?

Thank you!

It’s not your input boolean, it’s your tapo switch that’s causing the issue.

But if thats the case, why does the automation work if i get rid of the input boolean? All the Tapo switches work just fine on their own…

I’m not sure, but your error is pointing to your tapo switch malfunctioning.

1 Like