Help please - water_heater.set_operation_mode

I’m having a problem with a script I just wrote

  turn_water_heating_off:
    alias: Turn water heating off
    sequence:
    - service: water_heater.set_operation_mode
      data:
        entity_id: water_heater.hot_water
        operation_mode: off

  turn_water_heating_on:
    alias: Turn water heating on
    sequence:
    - service: water_heater.set_operation_mode
      data:
        entity_id: water_heater.hot_water
        operation_mode: eco

The second one, turn_water_heating_on works fine
The first one results in the error

Logger: homeassistant.components.websocket_api.http.connection.1752949592
Source: components/hive/water_heater.py:75
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 16:47:37 (2 occurrences)
Last logged: 16:51:50

'False'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 137, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1315, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1350, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 215, in service_handler
    await script_entity.async_turn_on(
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 320, in async_turn_on
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 944, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 198, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 206, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 413, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1315, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1350, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 459, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 655, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 490, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/water_heater/__init__.py", line 262, in async_set_operation_mode
    await self.hass.async_add_executor_job(self.set_operation_mode, operation_mode)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/hive/__init__.py", line 167, in wrapper
    func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/hive/water_heater.py", line 75, in set_operation_mode
    new_mode = HASS_TO_HIVE_STATE[operation_mode]
KeyError: 'False'

Can anyone tell me why? The only difference between the two is operation_mode: off vs operation_mode: eco both of which are valid operation_modes

Put off in quotes like 'off'

off without quotes is interpreted like a boolean (true/false value).

That simple!
Thanks @Tediore

1 Like