Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensor Rain delay errors on startup #15

Closed
TheGardenMonkey opened this issue May 25, 2020 · 17 comments
Closed

Sensor Rain delay errors on startup #15

TheGardenMonkey opened this issue May 25, 2020 · 17 comments
Assignees

Comments

@TheGardenMonkey
Copy link

TheGardenMonkey commented May 25, 2020

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'
@sebr sebr self-assigned this May 25, 2020
@sebr
Copy link
Owner

sebr commented May 25, 2020

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.

@sebr
Copy link
Owner

sebr commented May 26, 2020

@TheGardenMonkey turns out HACS doesn't support bundling both a custom component and a python script so you'll need to install it manually. Check out the docs here: https://github.com/sebr/bhyve-home-assistant#python-script

NB: You'll need to upgrade to version 0.2.0-alpha.2

@TheGardenMonkey
Copy link
Author

I can't figure out how to do the alpha / beta installs in HACS anymore lol. Any advice for how to do the upgrade in HACS or do I have to do it manually?

...And a huge thank you for this. I was giving up that we would ever get the bhyve ecosystem into HA. I have 3 active timers (i have a boxed one as well) and I would definitely like to help with any beta testing (or coding) you need for enhancements.

@sebr
Copy link
Owner

sebr commented May 27, 2020

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

@sebr
Copy link
Owner

sebr commented Jun 2, 2020

Did you manage to test this at all @TheGardenMonkey ? Keen for some feedback before releasing to the wild :)

@TheGardenMonkey
Copy link
Author

I did but it isn't updating, it is creating the sensors but just getting None for the next watering. I will attempt to debug in the morning.

@TheGardenMonkey
Copy link
Author

From what I see it is looking for an attribute that isn't on my devices. Line 40:

for timestamp in zone.attributes.get("watering_program", []) or []:

...my devices do not have a watering_program attribute as far as I can tell. Instead there is a "switch.program-name_program" that has a start_times and days attribute that looks like it should be parsed for the correct time.

Are you on discord, maybe I can send you some of the details of what mine look like? I can also give a shot updating it to support mine.

@sebr
Copy link
Owner

sebr commented Jun 3, 2020

Yep i'm in the HA server as sebr. Ping me there!

@AlexVercammen
Copy link

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 %}

@AlexVercammen
Copy link

@sebr . This is my 1st comment ever which explain my modest skill pinging someone in particular instead of the group.
My apologies.

@AlexVercammen
Copy link

@sebr . I forgot to ask. Can the Rain Delay sensor icon change when its state is off?
Obviously the remaining delay is 0 at that time.

@sebr
Copy link
Owner

sebr commented Jun 26, 2020

@AlexVercammen those sensors are a bit out of date and quite brittle. I would suggest moving to the python_script which I have written to solve this problem more reliably.

@sebr
Copy link
Owner

sebr commented Jun 26, 2020

@TheGardenMonkey haven't forgotten about this issue mate, just lost for time!

@TheGardenMonkey
Copy link
Author

No worries brother, I figured and all good. I can tell this is a bit tricky based on how that data comes in. Let me know if you need me to do anything. I was going to try to work on it myself but work has been busy.

@vmcosco
Copy link

vmcosco commented Jul 15, 2020

Having an issue with the python script _rain_delay_finishing returning "None" when I have a delay that started at 2020-07-15T15:36:41-04:00 with a delay of 24. The _next_watering is also returning "None" despite having a program on (albeit on a rain delay right now).

@sebr
Copy link
Owner

sebr commented Jul 16, 2020

@vmcosco I've pushed a change which adds some extra logging - can you check that out and see if you get any errors in the log? If you are still having troubles, can you please create a new issue with as many details as possible? Thanks!

@sebr
Copy link
Owner

sebr commented Jul 16, 2020

@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 :)

@sebr sebr closed this as completed Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants