TypeError: unsupported operand type(s) for *: 'function' and 'datetime.datetime'

This is a new one. Haven’t seen it before. What should I be looking for?

TypeError: unsupported operand type(s) for *: 'function' and 'datetime.datetime'

Especially as I have not done any new configuration with datetimes recently.

What have you been doing recently? :slight_smile:

It seems you have the * operator somewhere with a function on one side and a datetime on the other. So where are you seeing that? Could it be in a template? In some python_script? …? Can you provide any additional context around that message?

Think I’ve found it:

- platform: template
  sensors:
    projected_end:
      friendly_name: 'Projected End Date'
      entity_id: sensor.abb_usage
      value_template: >
        {% set next_start_ts = as_timestamp(state_attr('sensor.abb_usage', 'nextRollover'))  %}
        {% set total_sec = state_attr('sensor.abb_usage', 'daysTotal') | int  * 86400  %}
        {% set sec_left = ( 86400 * state_attr('sensor.abb_usage', 'remainingMb') | float / 1000 * state_attr('sensor.abb_usage', 'daysUsed') | int ) / (state_attr('sensor.abb_usage', 'usedMb') |         float / 1000) %}
        {{ (next_start_ts - total_sec + sec_left) | timestamp_custom('%A %-d %B %Y at %X', True)}}

Problem is that the abb sensor atributes dont initialise until a few seconds after start up.