claudegel / sinope-130

Neviweb130 custom component for Home Assistant to manage devices connected via a GT130 and wifi devices from Sinopé
GNU General Public License v3.0
73 stars 15 forks source link

Integration no longer starting with ACT4220WF-M and/or ACT4220ZB-M (Sedna mesh) #232

Closed dr1rrb closed 6 months ago

dr1rrb commented 6 months ago

Integration startup is failing due to missing key in device_data for ACT4220WF-M and/or ACT4220ZB-M valves (Sedna mesh devices).

I had to comment out flow and alarm1 related keys to get it to start :

                    """self._flowmeter_threshold = device_data[ATTR_FLOW_THRESHOLD]
                    self._flowmeter_alert_delay = device_data[ATTR_FLOW_ALARM1_PERIOD]
                    self._flowmeter_alarm_lenght = device_data[ATTR_FLOW_ALARM1_LENGHT]
                    self._flowmeter_opt_alarm = device_data[ATTR_FLOW_ALARM1_OPTION][ATTR_TRIGGER_ALARM]
                    self._flowmeter_opt_action = device_data[ATTR_FLOW_ALARM1_OPTION][ATTR_CLOSE_VALVE]"""

https://github.com/claudegel/sinope-130/blob/4daf00a6ca2e2a80be343c9c2a9afa18416bf9f6/custom_components/neviweb130/valve.py#L1044-L1048

claudegel commented 6 months ago

Do you have some log to show about the error ? Do you have the model for each valve

dr1rrb commented 6 months ago

Do you have some log to show about the error ?

2024-03-20 20:55:37.451 ERROR (MainThread) [homeassistant.components.valve] neviweb130: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 682, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1264, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/neviweb130/valve.py", line 1045, in update
    self._flowmeter_alert_delay = device_data[ATTR_FLOW_ALARM1_PERIOD]
                                  ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'alarm1Period'

(For this I commented only the ATTR_FLOW_THRESHOLD, I commented all the ATTR_FLOW_ALARM1_***)

Do you have the model for each valve

Yes.

The ACT4220WF-M is the "main" one, connected to the mesh WiFi network, while the second ACT4220ZB-M is only connected to the first one (and replicates its state) among all other zigbee sensors..

claudegel commented 6 months ago

ok just wanted to be sure, in your log you should see model 3155 for ACT4220WF-M and model 31532 for ACT4220ZB-M. Do you have flowmeter connected to your valve?

dr1rrb commented 6 months ago

Do you have the model for each valve

Oups misread the question. ACT4220WF-M and ACT4220ZB-M are model reported by the valves. They are the multi-residential vales : cf. https://github.com/claudegel/sinope-130/pull/97#issuecomment-1270932777

Do you have flowmeter connected to your valve?

No

BTW, looking at my previous commits, we already had such issue here https://github.com/claudegel/sinope-130/pull/145

claudegel commented 6 months ago

OK let me do some changes in valve.py

claudegel commented 6 months ago

There is a bug with git as I can't edit valve.py. You need to change

    self._flowmeter_timer = device_data[ATTR_FLOW_ALARM_TIMER]
    self._flowmeter_threshold = device_data[ATTR_FLOW_THRESHOLD]
    self._flowmeter_alert_delay = device_data[ATTR_FLOW_ALARM1_PERIOD]
    self._flowmeter_alarm_lenght = device_data[ATTR_FLOW_ALARM1_LENGHT]
    self._flowmeter_opt_alarm = device_data[ATTR_FLOW_ALARM1_OPTION][ATTR_TRIGGER_ALARM]
    self._flowmeter_opt_action = device_data[ATTR_FLOW_ALARM1_OPTION][ATTR_CLOSE_VALVE]

with:

    if ATTR_FLOW_ALARM_TIMER in device_data:
        self._flowmeter_timer = device_data[ATTR_FLOW_ALARM_TIMER]
        if self._flowmeter_timer != 0:
            self._flowmeter_threshold = device_data[ATTR_FLOW_THRESHOLD]
            self._flowmeter_alert_delay = device_data[ATTR_FLOW_ALARM1_PERIOD]
            self._flowmeter_alarm_lenght = device_data[ATTR_FLOW_ALARM1_LENGHT]
            self._flowmeter_opt_alarm = device_data[ATTR_FLOW_ALARM1_OPTION][ATTR_TRIGGER_ALARM]
            self._flowmeter_opt_action = device_data[ATTR_FLOW_ALARM1_OPTION][ATTR_CLOSE_VALVE]

It should fix it

dr1rrb commented 6 months ago

@claudegel yes it works :)

claudegel commented 6 months ago

Ok as soon as I find out why git cannot save my changes I'll make an update

claudegel commented 6 months ago

Ok I've updated valve.py in Error-message branch https://github.com/claudegel/sinope-130/tree/Error-message/custom_components/neviweb130 Do you have the latest version of neviweb130? 2.7.1

claudegel commented 6 months ago

Ok I'll push a new release. Feel free to reopen if any problem. Thank you for reporting that bug.

dr1rrb commented 6 months ago

Updated to 2.7.2, works great

Thanks @claudegel 👍