Timer.start TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'NoneType'

I’m really struggling to get this timer to accept a number of minutes from a input_number slider. Any help most appreciated.

This is the full error I receive when invoking timer.start automation

unsupported operand type(s) for +: 'datetime.datetime' and 'NoneType'

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1236, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1261, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 348, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 370, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/src/homeassistant/homeassistant/components/timer/__init__.py", line 175, in async_start
    self._end = start + self._duration
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'NoneType'

my config

## hot water boost
input_number:
  boost:
    name: boost
    initial: 30
    min: 30
    max: 120
    step: 10
    mode: slider

timer:
  boost:
    name: boost


#### my automations
- alias: Timer start
  trigger:
     platform: state
     entity_id: input_boolean.boost
     to: 'on'
  action:
   - service: timer.start
     data_template:
      entity_id: timer.boost
      duration: "{{ states('input_number.boost') | int * 60}}"


#   - service: switch.turn_on
#     entity_id: switch.water_boost_timer_switch_switch

- alias: Timer cancel
  trigger:
     platform: state
     entity_id: switch.water_boost_timer_switch_switch
     to: 'off'
  action:
     entity_id: timer.boost
     service: timer.cancel


- alias: Timer stop
  trigger:
     platform: event
     event_type: timer.finished
     event_data:
       entity_id: timer.boost
  action:
    entity_id: switch.water_boost_timer_switch_switch
    service: switch.turn_off

Are you sure that error message is from the service call of the automation? It looks more like you tried to call the timer.start service from the Developer Tools.

I don’t see anything wrong with the automation. What version of HA are you running?

I click start on the timer in the UI and thats the error that is shown bottom.

Home Assistant 0.102.1
on Ubuntu, in Docker HASSIO

If I use the imput_boolean.boost to start the timer it works, then the UI works to start and stop. If I think on a restart if i just open the timer in the UI and click start its throwing that error so my guess is some initial value isn’t set

Ah, didn’t know you could do that. That must be a relatively new feature.

Yes, I believe this is because you haven’t set the duration in the config.

EDIT: I’d say this is a bug. The default duration is supposed to be zero. Although that’s not very useful of a value, not specifying a value for duration in the config should not cause the (new) START button to cause an exception. You might want to log an issue.

I’ve added duration: 1800 and thats fixed the timer. i’ll adjust my automation to not need the input_boolen to start as I can use the timer UI instead. Sorry I seem to have confused myself chopping and changing code. I do find this YAML a struggle at times lol

Thanks for your help :smiley: