Problem with a few sensors

Hi all,
I have for a year now the following sensor which counts how many hours my air condition is on, and it was working fine. (as a matter of fact I have 3 air conditions so this is happened to all of them)

  - platform: history_stats
    name: Saloni 24h
    entity_id: binary_sensor.saloni_ac_on
    state: 'on'
    type: time
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'

Yesterday I added one more sensor which counts the average energy consumption per hour of the particular air condition

- platform: template
  sensors:
    toshiba_average_watts_per_hour:
      unit_of_measurement: "W"
      value_template: "{{'%.f' | format(states.sensor.saloni_aircon_daily_energy.state|round(1)/states.sensor.saloni_24h.state|round(1)*1000)}}"

Today I have 2 problems. First and most annoying is that my first sensor which counts the hours was wrong. The air condition was on all night so at 8 o’clock in the morning should be 8 (hours) but it was 4.30

The second sensor showed the following error in the logs

Logger: homeassistant.helpers.event
Source: helpers/template.py:408
First occurred: 07:40:28 (5 occurrences)
Last logged: 08:59:42

Error while processing template: Template("{{'%.0f' | format(states.sensor.saloni_aircon_daily_energy.state|round(1)/states.sensor.saloni_24h.state|round(1)*1000)}}")
Error while processing template: Template("{{'%.0f' | format(states.sensor.bedormm_aircon_daily_energy.state|round(1)/states.sensor.bedroom_24h.state|round(1)*1000)}}")
Error while processing template: Template("{{'%.f' | format(states.sensor.kid_aircon_daily_energy.state|round(1)/states.sensor.kid_24h.state|round(1)*1000)}}")
Error while processing template: Template("{{'%.f' | format(states.sensor.bedormm_aircon_daily_energy.state|round(1)/states.sensor.bedroom_24h.state|round(1)*1000)}}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 406, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1771, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
TypeError: unsupported operand type(s) for /: 'float' and 'str'

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 522, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 408, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: unsupported operand type(s) for /: 'float' and 'str'

and

Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:140
Integration: Template (documentation, issues)
First occurred: 07:40:28 (5 occurrences)
Last logged: 08:59:42

TemplateError('TypeError: unsupported operand type(s) for /: 'float' and 'str'') while processing template 'Template("{{'%.0f' | format(states.sensor.saloni_aircon_daily_energy.state|round(1)/states.sensor.saloni_24h.state|round(1)*1000)}}")' for attribute '_attr_native_value' in entity 'sensor.toshiba_average_watts_per_hour'
TemplateError('TypeError: unsupported operand type(s) for /: 'float' and 'str'') while processing template 'Template("{{'%.0f' | format(states.sensor.bedormm_aircon_daily_energy.state|round(1)/states.sensor.bedroom_24h.state|round(1)*1000)}}")' for attribute '_attr_native_value' in entity 'sensor.bedroom_aux_average_watts_per_hour'
TemplateError('TypeError: unsupported operand type(s) for /: 'float' and 'str'') while processing template 'Template("{{'%.f' | format(states.sensor.kid_aircon_daily_energy.state|round(1)/states.sensor.kid_24h.state|round(1)*1000)}}")' for attribute '_attr_native_value' in entity 'sensor.kid_aux_average_watts_per_hour'
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{{'%.f' | format(states.sensor.bedormm_aircon_daily_energy.state|round(1)/states.sensor.bedroom_24h.state|round(1)*1000)}}")' for attribute '_attr_native_value' in entity 'sensor.bedroom_aux_average_watts_per_hour'
TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template("{{'%.f' | format(states.sensor.kid_aircon_daily_energy.state|round(1)/states.sensor.kid_24h.state|round(1)*1000)}}")' for attribute '_attr_native_value' in entity 'sensor.kid_aux_average_watts_per_hour'

For the second sensor I think I have to add somethng in order stop divide with zero. But what is the problem with the first sensor which counts the hours. Is there a way the second sensor to “broke” somehow the first one?