bhyve-home-assistant: Sensor Rain delay errors on startup

The following appears in my home-assistant log upon every restart for the rain_delay_*_remaining and rain_delay_*_finishing for each device:

2020-05-25 14:03:44 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.rain_delay_deck_finishing fails
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 470, in async_device_update
    await self.async_update()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/template/sensor.py", line 224, in async_update
    self._state = self._template.async_render()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/template.py", line 228, in async_render
    return compiled.render(kwargs).strip()
  File "/srv/homeassistant/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/srv/homeassistant/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/srv/homeassistant/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

Those rain_delay_finishing and rain_delay_remaining sensor examples are a bit… fragile. They were indicative only.

However - I do have a python_script which creates and updates sensors to do this which I’ll package up into a release. Will need a day or two to publish a beta release.

@TheGardenMonkey I’m going to close this issue as the original startup errors have been fixed. I am aware of the limitation of the next watering script ignoring non-smart watering programs 😃

I’ve installed your HACS last weekend and it was a flawless installation. The only struggle I had was with the sensor templates. They would only refresh after restarting. So I’ve created then added the “entity_id: sensor.time” to the templates. Also I change the timestamp to a custom and just get the day of the next watering. I have NOT updated to your latest version yet! So this could be irrelevant. (Installed: 0.1.13)

sensor:
  - platform: time_date
    display_options:
      - time
  - platform: template
    sensors:
      rain_delay_lawn_remaining:
        friendly_name: "Rain Delay Remaining"
        entity_id: sensor.time
        unit_of_measurement: "h"
        availability_template: "{{ states('binary_sensor.rain_delay_b_hyve_timer') != 'unavailable' }}"
        value_template: "{{ ((as_timestamp(state_attr('binary_sensor.rain_delay_b_hyve_timer', 'started_at')) + state_attr('binary_sensor.rain_delay_b_hyve_timer', 'delay') * 3600 - as_timestamp(now())) / 3600) | round(0) }}"

      lawn_next_watering:
        friendly_name: "Next watering"
        entity_id: sensor.time
        availability_template: "{{ states('switch.backyard_zone') != 'unavailable' }}"
        value_template: >-
          {% set program = state_attr('switch.backyard_zone', 'watering_program') -%}
          {% if program and (program | count > 0) %}
            {{ as_timestamp(program[0]) | timestamp_custom('%A',false) }}
          {% else %}
            unknown
          {% endif %}

Go to HACS → Orbit BHyve → Reinstall → Show Beta Versions Screen Shot 2020-05-27 at 10 57 01 am Screen Shot 2020-05-27 at 10 57 31 am