rgc99 / irrigation_unlimited

♒Irrigation controller for Home Assistant
MIT License
330 stars 49 forks source link

Notification for irrigation_unlimited_switch_error, irrigation_unlimited_sync_error not working #115

Open Kurisutian opened 1 year ago

Kurisutian commented 1 year ago

Describe the bug I've used the example for a notification on irrigation_unlimited_switch_error, irrigation_unlimited_sync_error as described in the documentation. However for some reason HA does have an issue with it:

Logger: homeassistant.components.automation.irrigation_unlimited_switch_error
Source: helpers/script.py:410
Integration: Automatisierung (documentation, issues)
First occurred: 4. Juni 2023 um 04:43:47 (13 occurrences)
Last logged: 08:10:37

Irrigation Unlimited Switch Error: Error executing script. Error for call_service at pos 1: Error rendering data template: TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
Irrigation Unlimited Switch Error: Error executing script. Error for call_service at pos 1: Error rendering data template: UndefinedError: 'dict object' has no attribute 'event'

To Reproduce Steps to reproduce the behavior:

  1. Create the Automation from the docs
  2. Wait for an sync error for a switch
  3. Check the HA Logs
  4. See error

Expected behavior A notification is being sent out

Additional context Using shelly devices as switches it seems that for some reason the first one in the sequence fails quite often. It might however just be a coincidence.

rgc99 commented 1 year ago

I have zigbee switches and not without dramas hence the whole check back thing. Perhaps the notification is for the controller which might produce the error. I have added a couple of lines to test the zone is valid.

automation:
  - id: "IU1653340138435"
    alias: "Irrigation Unlimited Switch Error"
    description: "Email a switch syncronisation error"
    trigger:
      - platform: event
        event_type:
          # - irrigation_unlimited_sync_error
          - irrigation_unlimited_switch_error
    action:
      - service: notify.NOTIFIER_NAME # Make sure this matches the "NOTIFIER_NAME" in the smtp setup
        data:
          title: "Irrigation Switch Error"
          message: |
            Type: {{ trigger.event.event_type }}
            Time: {{ as_local(trigger.event.time_fired).strftime('%c') }}
            Expected: {{ trigger.event.data.expected }}
            Controller: {{ trigger.event.data.controller.index + 1 }} {{ trigger.event.data.controller.name }}
            {% if trigger.event.data.zone.index is not none %}
              Zone: {{ trigger.event.data.zone.index + 1 }} {{ trigger.event.data.zone.name }}
            {% endif %}
            Entity: {{ trigger.event.data.entity_id }}
Kurisutian commented 1 year ago

Thanks a lot for the quick reply. Out of curiosity, which devices are you using? I was considering switching away from the Shelly1 devices to zwave, but not with Matter and Thread if seems like it's better to wait till there will be more devices for it and also not keep looking into zwave to much.

rgc99 commented 1 year ago

In Australia zwave operates on a different frequency. It means manufacturers have to produce a special version. Quite often they choose not to make one because the market is too small and if they do it usually takes a long time. This limits the choice of devices available. For this reason I use zigbee.

Every thing you wanted to know https://community.home-assistant.io/t/irrigation-unlimited-integration/325468/152?u=rgc99

Kurisutian commented 1 year ago

Yeah, I was just curious about the Zigbee devices you're using. I adjusted the automation and it seems to work. However it throws quite a lot of "errors" for the controller rather than the individual switches. Also it seems like one switch in particular does quiet often not run but the other one does. Not sure if this is a bug, a issue with the switch or something else. Manual runs are always working with that switch but the automation to run in sequence (while it's the first one to run) is pretty unreliable. Is there any way I can debug that a bit better? It's weird that the first in the sequence mostly fails while the second one never does....