petergridge / Irrigation-V5

Irrigation custom component for Home Assistant
GNU General Public License v3.0
53 stars 9 forks source link

Event program_turned_off is never call #61

Open Loic691 opened 3 weeks ago

Loic691 commented 3 weeks ago

Hi @petergridge Event _irrigationevent is never call when programs stops. I saw the log this morning on my mobile phone but I loose it. I will send you this log for the next program cycle, not tomorrow because raining is announce on openwheathermaphistory ;-) Probably in this week !

And thanks for all; This integration is working perfectly ;-)

My code

alias: Auto - Jardin - Arrosage - Fin programme
description: ""
trigger:
  - platform: event
    event_type: irrigation_event
    event_data:
      action: program_turned_off
      scheduled: true
condition: []
action:
  - service: notify.telegram_loic
    metadata: {}
    data:
      title: Irrigation
      message: Fin programm Arrosage {{ trigger.event.data.device_id }}
mode: single
petergridge commented 3 weeks ago

Hi @Loic691

It looks like you have specified extra attributes in the event data, 'scheduled' is not a data item for the off event so your automation will not fire.

https://github.com/petergridge/Irrigation-V5#events

image

image

If you need the scheduled attribute I can add it, I couldn't think of a use case for it.

The completed attribute will return 'true' if the program completed as expected and false if it was terminated.

It's great to see people using the events I wasn't sure if they would be useful and wondered if I was making the program more complicated than required.

Cheers Pete

petergridge commented 3 weeks ago

Hi,

One more note you can monitor events from the developer tools menu:

image

Loic691 commented 3 weeks ago

Oh sheet ! Don't read the off event... No not need the schedduled for off event. I will remove now this attributes and let you know. Sorry for opening issues

Loic691 commented 3 weeks ago

And for me events are usefull. I take water index at each starts and ends of each program to compute water volume and cost for flowers, the house border plants and grasse lawn !

petergridge commented 3 weeks ago

Not a problem, I prefer issues that don't need me to fix the code 😄, and questions are always welcome. It's taken almost 5 years to get to this point and every time I think the program is stable and could not need any more features someone has a good idea or HA changes and the program needs to keep up.

This has become something of a hobby and I enjoy the interaction with people all over the world. I am in Australia and from what I can see most users are in Europe and North America.

Loic691 commented 3 weeks ago

Here's I always have in my log

Enregistreur: homeassistant.core
Source: core.py:2559
S'est produit pour la première fois: 05:58:00 (3 occurrences)
Dernier enregistrement: 09:56:00

Error executing service: <ServiceCall irrigationprogram.stop_programs (c:01HV0G2VA4N30XP3W3H6T78DFB): ignore=Prog2>
Error executing service: <ServiceCall irrigationprogram.stop_programs (c:01HV0T8S094SRYCHKR7ST1KC4K): ignore=Irrigation Prog1>
Error executing service: <ServiceCall irrigationprogram.stop_programs (c:01HV0XPMM49RWBSF8GEAVVMQC4): ignore=Bordure Maison>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2559, in _run_service_call_catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/irrigationprogram/__init__.py", line 104, in async_stop_programs
    if hass.states.get(device).state == "on":
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
Loic691 commented 3 weeks ago

Not a problem, I prefer issues that don't need me to fix the code 😄, and questions are always welcome. It's taken almost 5 years to get to this point and every time I think the program is stable and could not need any more features someone has a good idea or HA changes and the program needs to keep up.

This has become something of a hobby and I enjoy the interaction with people all over the world. I am in Australia and from what I can see most users are in Europe and North America.

Oh Yeah ;-) I'm in french alps moutains

petergridge commented 2 weeks ago

The error you are seeing in your log, I see a similar error when a program has a zone defined where the referenced switch no longer exists, maybe the name changed.

petergridge commented 2 weeks ago

I was in France November last year for 4 weeks, spent a week in Dordogne, then onto Bordeaux, Loire valley and finally a week in Paris. It is a beautiful country and still so much more to see

Loic691 commented 1 week ago

The error you are seeing in your log, I see a similar error when a program has a zone defined where the referenced switch no longer exists, maybe the name changed.

Hi My entities doesn't change... In contrast I have delete zones to create it in other program.. Maybe this is it and a little bug ? Recently, I hid all switch zone entities (but exists) because I change the type of the switch to valve (a new type in HA in my memory)

This error is trigered each day even if I have no program running in the day

Loic691 commented 1 week ago

I was in France November last year for 4 weeks, spent a week in Dordogne, then onto Bordeaux, Loire valley and finally a week in Paris. It is a beautiful country and still so much more to see

Great, but you forgot the alps valley ;-)

petergridge commented 1 week ago

Hi,

I can recreate this issue now. I created a program with ' ' (a space) as the program name. Then deleted it. This caused the error.

To fix this you will need to delete the component and reconfigure again.

I will put a fix into the next release to stop blank program names

Loic691 commented 1 week ago

Hi,

I can recreate this issue now. I created a program with ' ' (a space) as the program name. Then deleted it. This caused the error.

To fix this you will need to delete the component and reconfigure again.

I will put a fix into the next release to stop blank program names

Are you sure this will fiw my issue in error log ? I just removed zone and created in other new program. Never changed names with blank one. I done your update, let's see tomorrow morning

petergridge commented 1 week ago

Running the stop programs service will give the error if it still happens

Loic691 commented 1 week ago

I done the update and launch Stop programs service. I have always the error

Enregistreur: homeassistant.components.websocket_api.http.connection
Source: custom_components/irrigationprogram/__init__.py:105
intégration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [problèmes](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
S'est produit pour la première fois: 11:44:34 (1 occurrences)
Dernier enregistrement: 11:44:34

[139982059844288] Error handling message: Unknown error (unknown_error) pierre from 192.168.2.67 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 794, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1713, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 457, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 509, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 539, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 507, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/irrigationprogram/__init__.py", line 105, in async_stop_programs
    if hass.states.get(device).state == "on":
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'

I don't know how to get the name of object...

petergridge commented 1 week ago

Ignore my previous post if you received it, I found that if I deleted a zone and then ran the stop zones service I got the error, but if I restarted HA I did not.

petergridge commented 1 week ago

I am missing the handling of removing an entry from the config flow. This still does not explain why you have a continuing issue with an entry not being found.

petergridge commented 1 week ago

V5.4.13 (beta) has been released, I don't know if it will fix your issue but I have added a list_configuration service that will show how your env is configured it would be interesting if this service shows anything different to what you have in the configuration.

Loic691 commented 1 week ago

Hi Tanks for your reponse. Same issue with your last version Here's the content of config

Cette erreur provient d'une intégration personnalisée

Enregistreur: custom_components.irrigationprogram
Source: custom_components/irrigationprogram/__init__.py:138
intégration: Irrigation controller (documentation, problèmes)
S'est produit pour la première fois: 06:54:43 (3 occurrences)
Dernier enregistrement: 12:24:44

Program 1 name:Irrigation Prog1 start_time:input_datetime.irrigation_plantes_starttime Zone 1 zone:switch.rt2_relay02_irrigation_gabionsud water:input_number.irrigation_duree_plantes_gabion rain_sensor:binary_sensor.irrigation_rain_sensor ignore_rain_sensor:input_boolean.irrigation_disabled_rain_sensor enable_zone:input_boolean.irrigation_zone2_enable Zone 2 zone:switch.rt2_relay05_irrigation_haiesud water:input_number.irrigation_duree_haie_sud rain_sensor:binary_sensor.irrigation_rain_sensor ignore_rain_sensor:input_boolean.irrigation_disabled_rain_sensor enable_zone:input_boolean.irrigation_zone5_enable Zone 3 zone:switch.rt2_relay09_irrigation_haieouest water:input_number.irrigation_duree_haie_ouest rain_sensor:binary_sensor.irrigation_rain_sensor ignore_rain_sensor:input_boolean.irrigation_disabled_rain_sensor enable_zone:input_boolean.irrigation_zone9_enable show_config:input_boolean.irrigation_showoptions device_type:generic run_freq:input_select.irrigation_frequency_plantes irrigation_on:input_boolean.irrigation_plantes_enabled inter_zone_delay:input_number.irrigation_interzonedelai interlock:True Program 2 name:Prog2 start_time:input_datetime.irrigation_pelouse_starttime Zone 1 zone:switch.rt2_relay03_irrigation_pelouseest water:input_number.irrigation_duree_pelouse_est wait:input_number.irrigation_time_between_cycle repeat:input_number.irrigation_cycle_number water_adjustment:sensor.rain_factor rain_sensor:binary_sensor.irrigation_rain_or_clothes ignore_rain_sensor:input_boolean.irrigation_disabled_rain_sensor enable_zone:input_boolean.irrigation_zone3_enable Zone 2 zone:switch.rt2_relay04_irrigation_pelousesudest water:input_number.irrigation_duree_pelouse_sudest wait:input_number.irrigation_time_between_cycle repeat:input_number.irrigation_cycle_number water_adjustment:sensor.rain_factor rain_sensor:binary_sensor.irrigation_rain_sensor ignore_rain_sensor:input_boolean.irrigation_disabled_rain_sensor enable_zone:input_boolean.irrigation_zone4_enable Zone 3 zone:switch.rt2_relay07_irrigation_pelouseouest water:input_number.irrigation_duree_pelouse_ouest wait:input_number.irrigation_time_between_cycle repeat:input_number.irrigation_cycle_number water_adjustment:sensor.rain_factor rain_sensor:binary_sensor.irrigation_rain_sensor ignore_rain_sensor:input_boolean.irrigation_disabled_rain_sensor enable_zone:input_boolean.irrigation_zone7_enable Zone 4 zone:switch.rt2_relay08_irrigation_pelousesud water:input_number.irrigation_duree_pelouse_sud wait:input_number.irrigation_time_between_cycle repeat:input_number.irrigation_cycle_number water_adjustment:sensor.rain_factor rain_sensor:binary_sensor.irrigation_rain_sensor ignore_rain_sensor:input_boolean.irrigation_disabled_rain_sensor enable_zone:input_boolean.irrigation_zone8_enable show_config:input_boolean.irrigation_showoptions device_type:generic run_freq:input_select.irrigation_frequency_pelouse irrigation_on:input_boolean.irrigation_pelouse_enabled inter_zone_delay:input_number.irrigation_interzonedelai interlock:True Program 3 name:Bordure Maison start_time:input_datetime.irrigation_bordure_maison_starttime device_type:generic interlock:True run_freq:input_select.irrigation_frequency_bordure_maison irrigation_on:input_boolean.irrigation_bordure_maison_enabled inter_zone_delay:input_number.irrigation_interzonedelai Zone 1 zone:switch.rt2_relay01_irrigation_maisonsud water:input_number.irrigation_duree_plantes_maison_sud enable_zone:input_boolean.irrigation_zone1_enabled rain_sensor:binary_sensor.irrigation_rain_sensor_bordure_maison Zone 2 zone:switch.rt2_relay10_irrigation_maisonouest water:input_number.irrigation_duree_maison_ouest enable_zone:input_boolean.irrigation_zone10_enable rain_sensor:binary_sensor.irrigation_rain_sensor_bordure_maison

Nothings seams in unknow or error state...

Loic691 commented 1 week ago

Maybe program names with space ?

petergridge commented 1 week ago

Hi I have publish version 5.4.14-alpha with some error handling to see if we can get more information. I think this will capture what is triggering the error. You will see a message like this in the log "Could not find Program implementation %s, ignored" %s will be the program causing the problem, switch.program_name.

Loic691 commented 1 week ago

Hello Thx very much. Yes we have ;-)

Cette erreur provient d'une intégration personnalisée

Enregistreur: custom_components.irrigationprogram
Source: custom_components/irrigationprogram/__init__.py:116
intégration: Irrigation controller (documentation, problèmes)
S'est produit pour la première fois: 09:47:58 (2 occurrences)
Dernier enregistrement: 09:47:58

Could not find Program implementation switch.irrigation_prog1, ignored
Could not find Program implementation switch.prog2, ignored

Your initial idea was good !!! These two programms are very old one I have when I tested your Irrigation v5 ;-)

So how to delete them (these old programs) because they don't appears in my program list ? image

In addition

Loic691 commented 1 week ago

I tried to change the entity name of irrigation switch and that's the problem ! So I don't know how to link the program to the irrigation switch... And remove old programs that are not displayed on the main pannel image

petergridge commented 1 week ago

Can you see them in the developer tools, states page, maybe you can delete them from there

Loic691 commented 1 week ago

No Is it possible to change or relink switch to program ? I think i have broken my config for the tests I don't show anywhere my old switch... The information must be somewhere

petergridge commented 1 week ago

Look in the  .storage directory that is where HA keeps the config information.  Make backup before changing anything. Sent from my Galaxy -------- Original message --------From: Loic69 @.> Date: 26/4/24 9:03 pm (GMT+10:00) To: petergridge/Irrigation-V5 @.> Cc: Peter @.>, State change @.> Subject: Re: [petergridge/Irrigation-V5] Event program_turned_off is never call (Issue #61) No Is it possible to change or relink switch to program ? I think i have broken my config for the tests I don't show anywhere my old switch... The information must be somewhere

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you modified the open/close state.Message ID: @.***>

Loic691 commented 6 days ago

Look in the  .storage directory that is where HA keeps the config information.  Make backup before changing anything. Sent from my Galaxy -------- Original message --------From: Loic69 @.> Date: 26/4/24 9:03 pm (GMT+10:00) To: petergridge/Irrigation-V5 @.> Cc: Peter @.>, State change @.> Subject: Re: [petergridge/Irrigation-V5] Event program_turned_off is never call (Issue #61) No Is it possible to change or relink switch to program ? I think i have broken my config for the tests I don't show anywhere my old switch... The information must be somewhere —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you modified the open/close state.Message ID: @.***>

In which file ?

Loic691 commented 4 days ago

For information after renamed switch program to the original names, the warning disapears from the log. So yes I think there is an old information to delete in the .storage directory. I don't find a special directory for irrigation V5. I don't know which file modify to delete old information definitively Have a good end of we ;-)

petergridge commented 2 days ago

Hi, Sorry life got in the way of answering some of these the last few days.

If you cannot see them in the developer tool/states or settings/devices and services/entities and remove them using these dialogs.

Check the core.entity_registry, core.device_registry and core.config_entries files they are most likely in the entity_registry but I have found references are often in multiple files. Be careful not to delete your active config if you move into this space.

Remember backup first :)