osks / hass-gardena-smart-system

Moved to https://github.com/py-smart-gardena/hass-gardena-smart-system
Apache License 2.0
4 stars 2 forks source link

Irrigation Control: Switch doesn't represent valve status. #3

Closed thecem closed 4 years ago

thecem commented 4 years ago

Thanks for this Integration!

A valve of the irrigation control could be activated via switch. And the valve could be closed if you activate the switch an deactivate it within 3 sec. Afterwards the switch go to off and don't represent the status of the valve.

If you need logs, let me know.

wijnandtop commented 4 years ago

Check, same here.

osks commented 4 years ago

I don't have an obvious idea what the problem could be. It would be really helpful if I could get debug logs for when this happens.

Enable them with this in configuration.yaml:

logger:
  default: info
  logs:
    custom_components.gardena_smart_system: debug
    custom_components.gardena_smart_system.mower : debug
    custom_components.gardena_smart_system.sensor : debug
    custom_components.gardena_smart_system.switch : debug
    custom_components.gardena_smart_system.config_flow : debug
    gardena: debug
    gardena.smart_system: debug

You probably want to read through the logs and sensor/remove potential secrets before giving them to someone else or attaching it here. If you think it would be better to only give the logs to me, rather than posting them for public, send me an email (see my github profile).

wijnandtop commented 4 years ago

Created a MR, mapping from activity to state (open closed) appears to be fixed. But there is stil an issue.

wijnandtop commented 4 years ago

My logs for an received update:

https://gist.github.com/wijnandtop/d3c39b8e118ce6548f8f2ac5b49b0c5b

thecem commented 4 years ago

do you need more logs ? If yes pls let me know. I updated the files, but no change for the irrigation control.

thecem commented 4 years ago

My log:

activating Rasen wait (switch going off/ Valve stays open) activating Rasen wait (switch going off/ Valve stays open) activating Rasen switch immediate back to off (switch going off/ Valve closes)

HA_gardena_smart_log.txt

osks commented 4 years ago

I think I've found the issue and fixed it now.

In GardenaSmartIrrigationControl each instance gets a reference to the device and the specific valve that entity represents. The valve is stored as self._valve. That is just a regular dict.

In SmartIrrigationControl.update_device_specific_data() (in py-smart-gardena2) it actually replaces that dict with a new dict:

        if device_map["type"] == "VALVE":
            self.valves[device_map["id"]] = {
 ...

The GardenaSmartIrrigationControl entity now only stores the valve_id and looks up the valve information instead.

Since I don't own an irrigation control myself I need help with testing this.

wijnandtop commented 4 years ago

Will give it a try later today :-) thanks!

osks commented 4 years ago

Thanks a lot to @thecem for the logs and to @wijnandtop for logs and PR. I took @wijnandtop's fix for the activity strings from PR #7.

wijnandtop commented 4 years ago

Too curious to wait... tested... and works perfectly. Changes in the gardena app are reflected in HASS immediately. Watering triggered from HASS results in watering en is also properly reflected in HASS.

thecem commented 4 years ago

d’accord! Works perfect, thanks @wijnandtop and @osks! Let me know if you need other support, log or something else, if I´m able to help I will do!

thecem commented 4 years ago

@wijnandtop if you switch a vlave on, is the switch after 3 sec in HA fliping off and then immediately on again? If you switch it to off, goes it to off and on again (this correct) regarding the valve pressure reduce time out of the gardena irrigation control waits 10 sec and then goes off? Do you have the same behaviour?

wijnandtop commented 4 years ago

@thecem no "Flipping" behaviour here.

Switch on/off from HASS : no flipping switches in HASS. Switching on/off from android app: no flipping switches in HASS.

Changes are immediately visible in both the app and HASS, immediate response at the physical valve.

thecem commented 4 years ago

Ok, I tested this also with older integrations of Gardena, same behaviour. I have one of the first Irrigation controller and first gateway version. Changes are also immediately visible in HA and valve. Only the flickering thing with the switch, but no show stopper.

Thanks a lot!