Error for call_service at pos 6

Can someone please explain “pos 6”? I’m looking for what Home Assistant thinks of as a division by zero that isn’t there as far as I can tell. I’m hoping that the pos 6 will direct me to a line or an action,

Thanks, Tom. But nothing you said or pointed to in the docs (at least that I could find) explains what “POS” stands for, which is really all I wanted to know…

Cheers, Nat

Post the full error text.

Logger: homeassistant.components.automation.daily_update_before_midnight
Source: helpers/script.py:2026
integration: Automation (documentation, issues)
First occurred: September 18, 2024 at 11:58:00 PM (1 occurrences)
Last logged: September 18, 2024 at 11:58:00 PM

Daily update before midnight: Error executing script. Error for call_service at pos 6: Error rendering data template: ZeroDivisionError: division by zero

Post this automation’s config:

automation.daily_update_before_midnight

The puzzling thing is that this works correctly every night.

alias: Daily update before midnight
description: ""
trigger:
  - platform: time
    at: "23:58:00"
condition: []
action:
  - target:
      entity_id: input_number.daily_furnace_usage
    data_template:
      value: "{{states('sensor.furnace_daily_usage')|int(1)|round(2)}}"
    action: input_number.set_value
  - data_template:
      value: >-
        {{(states('input_number.accumulative_temp')|float(0) +
        states('sensor.daily_average_temperature')|float(0))|round(2)}}
    target:
      entity_id: input_number.accumulative_temp
    action: input_number.set_value
  - data: {}
    target:
      entity_id: counter.days_since_the_beginning_of_the_season
    action: counter.increment
  - target:
      entity_id: input_number.propane_left
    data_template:
      value: >-
        {{(states('input_number.propane_left')|float(0) -
        states('sensor.furnace_on_today')|float(1) - 0.75)|float(0)}}
    action: input_number.set_value
  - target:
      entity_id: input_number.propane_since_start_of_winter
    data_template:
      value: >-
        {{(states('input_number.propane_since_start_of_winter')|float(0) +
        states('sensor.furnace_on_today')|float(0) + 0.2)|round(2) }}
    action: input_number.set_value
  - target:
      entity_id: input_text.propane_color
    data_template:
      value: >-
        {% if states('input_number.propane_left')|float(0) < 30 %}red{% else    
        %}#4f7ec9{% endif %}
    action: input_text.set_value
  - target:
      entity_id: input_number.morning_heat_differential
    data_template:
      value: >-
        {{(states('input_number.morning_outside_temperature')|float(1) /
        states('input_number.morning_inside_temperature')|float(1))|round(2)}}
    action: input_number.set_value
  - target:
      entity_id: input_datetime.propane_delivered_date
    data_template:
      date: >-
        {% if  states('input_datetime.propane_delivered_date') < 
        states('input_datetime.propane_delivered_date_previous') %}
        {{states('input_datetime.propane_delivered_date')}} {% else %}
        {{states('input_datetime.propane_delivered_date_previous')}} {% endif %}
    action: input_datetime.set_datetime
  - target:
      entity_id: input_number.propane_delivered_amount_previous
    data_template:
      value: >-
        {% if states('input_number.propane_delivered_amount_previous')|float(0)
        != states('input_number.propane_delivered_amount')|float(0) %}
        {{states('input_number.propane_delivered_amount')|float(0)}} {% else
        %}{{states('input_number.propane_delivered_amount')|float(0)}}{% endif
        %}           
    action: input_number.set_value
  - target:
      entity_id: input_number.propane_cost_previous
    data_template:
      value: >-
        {% if states('input_number.propane_cost_previous')|float(0) !=
        states('input_number.propane_cost')|float(0) %}
        {{states('input_number.propane_cost')|float(0)}} {% else %}
        {{states('input_number.propane_cost_previous')|float(0)}} {% endif %}
    action: input_number.set_value
  - target:
      entity_id: input_text.propane_icon
    data_template:
      value: >-
        {% if states('input_number.propane_left')|float(0) < 30 %}alert{% else
        %}hydraulic-oil-level{% endif %}
    action: input_text.set_value
  - data:
      config_entry: xxx
      data:
        Propane delivered date: "{{states('input_datetime.propane_delivered_date')}}"
        Delivered amount: "{{states('input_number.propane_delivered_amount')}}"
        Propane cost: "{{states('input_number.propane_cost')}}"
        Daily Furnace Usage: "{{states('sensor.furnace_daily_usage')}}"
        Propane Left: "{{states('input_number.propane_left')}}"
        Propane since start of winter: "{{states('input_number.propane_since_start_of_winter')}}"
        Sunrise: "{{states('sensor.nextsunrise')}}"
        Sunset: "{{states('sensor.nextsunset')}}"
        Conditions: "{{states('input_text.conditions')}}"
        Morning temperature: "{{states('input_number.morning_outside_temperature')}}"
        Inside Temp: "{{states('input_number.morning_inside_temperature')}}"
        Temp Differential: "{{states('input_number.morning_heat_differential')}}"
        Morning Heating Time: "{{states('input_number.morning_heating')}}"
        Day's Total Heating Time: "{{states('sensor.furnace_daily_usage')}}"
        Daily Average Temperature: "{{states('sensor.daily_average_temperature')}}"
        Weekly Average Temperature: "{{states('sensor.weekly_average_temperature')}}"
        Monthly Average Temperature: "{{states('sensor.monthly_average_temperature')}}"
        Average Temp Since Start of Season: >-
          {{(states('input_number.accumulative_temp')|float(1)/states('counter.days_since_the_beginning_of_the_season')|int(1))|round(2)}}
        Days in Season: "{{states('counter.days_since_the_beginning_of_the_season')|int(1)}}"
    action: google_sheets.append_sheet
  - data:
      config_entry: xxx
      data:
        Daily Average Temperature: "{{states('sensor.daily_average_temperature')}}"
        Daily Furnace Usage: "{{states('sensor.furnace_daily_usage')}}"
        Sunrise: "{{states('sensor.nextsunrise')}}"
        Sunset: "{{states('sensor.nextsunset')}}"
        Average Temp Since Start of Season: >-
          {{(states('input_number.accumulative_temp')|float(1)/states('counter.days_since_the_beginning_of_the_season')|int(1))|round(2)}}
    action: google_sheets.append_sheet
mode: single

This is position 6:

  - target:
      entity_id: input_number.morning_heat_differential
    data_template:
      value: >-
        {{(states('input_number.morning_outside_temperature')|float(1) /
        states('input_number.morning_inside_temperature')|float(1))|round(2)}}
    action: input_number.set_value

Look at the history of input_number.morning_inside_temperature is its value 0 at any point?

Hi Tom, I had to allow recording of the apps to see what kind of data I’m getting. No gaps or holes as far as I can tell. I do occasionally get similar gaps on devices when they drop out for a moment but it seems to be happening only to internal templates–& helpers in particular. Is there a way of getting around the problem? Thanks.

I have no idea what that means.

That is not what I asked.

This is what causes division by zero errors, not gaps.

Sorry–I should have said no zeros either.

It’s an input_number set once about 18 hours earlier in the day that never hits zero or has gaps, yet the division is always marked by the logs as being ‘division by zero’. And it doesn’t stop the automation & sends the correct value to a Google spreadsheet…