py-smart-gardena / hass-gardena-smart-system

Home Assistant custom component integration for Gardena Smart System
Apache License 2.0
213 stars 53 forks source link

START_DONT_OVERRIDE not available for mower #38

Open malundqvist opened 4 years ago

malundqvist commented 4 years ago

I can't find any vacuum service to issue a "resume schedule" command to the mower. Is this possible to add? I believe START_DONT_OVERRIDE is the API command. I used this command to resume scheduled operations after it has stopped raining, with help of IFTTT. IFTTT does not work anymore after adding this component (IFTTT gets logged out frequently) and therefore it would be great to find it in the component.

Jpsy commented 4 years ago

This is contained in #2 . Issue can be closed.

grm commented 4 years ago

Hey @Jpsy ,

I made some tests a few monthes ago (related to #2), but from what i remember, you could only resume normal operations. I will have to do some testing, because, for a reason I don't remember, i did't write down my test results :(, and i don't remember the results either :p

But from what I can remember, not all possibilities were covered with the actions, and on was missing (but now my mower does not works as expected, moles cut some lines :p in the garden ...)

Jpsy commented 4 years ago

Hi @grm,

AFAIR the problem in #2 was, that we did not succeed to find 4 different service calls in HA that would trigger the 4 mower commands that we would like to use. The vacuum integration of HA actually provides 5 calls:

  1. vacuum.start
  2. vacuum.stop
  3. vacuum.return_to_base
  4. vacuum.turn_on
  5. vacuum.turn_off

But unfortunately in all my tests I could only receive 1. to 3. in the custom component, but not 4. and 5. The last two service calls don't make it through to our code and I am not knowledgeable enough to determine the cause.

So we are stuck with three service calls and we had to map only 3 of the 4 desirable commands, which we did. A good mapping for 4 commands is already described in #2.

crazyfx1 commented 3 years ago

But unfortunately in all my tests I could only receive 1. to 3. in the custom component, but not 4. and 5. The last two service calls don't make it through to our code and I am not knowledgeable enough to determine the cause.

I think the issue is that StateVacuumEntity is used as base class instead of VacuumEntity. The StateVacuumEntity can't be turned on/off because the status is derived from the current state of the vacuum/mower. That means if the state is on the entity is also on.

jlatvala commented 2 years ago

The only Gardena API command, which is not working is START_DONT_OVERRIDE. If StateVacuumEntity's turn_on doesn't work, maybe you could implement own function for START_DONT_OVERRIDE? Similar as Husqvarna component's 'husqvarna_automower.park_and_start', see https://github.com/Thomas55555/husqvarna_automower

Or maybe reuse even more of those Husqvarna codes (as Husqvarna and Gardena APIs are similar)?

crazyfx1 commented 2 years ago

Well you actually just need to change the base class from StateVacuumEntity to VacuumEntity and then it works.

jlatvala commented 2 years ago

Well you actually just need to change the base class from StateVacuumEntity to VacuumEntity and then it works.

VacuumEntity is deprecated and will be removed in future releases. Please use or migrate to the StateVacuumEntity https://developers.home-assistant.io/docs/core/entity/vacuum/

crazyfx1 commented 2 years ago

That's too bad, maybe it's time for https://github.com/home-assistant/architecture/issues/40

jlatvala commented 2 years ago

As a workaround, can I easily modify vacuum.start to use START_DONT_OVERRIDE instead of START_SECONDS_TO_OVERRIDE?

I guess changing this self._device.start_seconds_to_override(duration) to this self._device.start_dont_override() could do the trick? (here https://github.com/py-smart-gardena/hass-gardena-smart-system/blob/911ffb9c70fb8cd74922b8b65a6063670699db55/custom_components/gardena_smart_system/vacuum.py#L174 )

Or do I need to change something else too?

(Sorry, I am not familiar with HA implementation or python even have coded a lot in the past (and after that worked as a SW & solution architect the last ~13 years)

jlatvala commented 2 years ago

I just realized that Gardena API's START_DONT_OVERRIDE (MowerCommand) doesn't require seconds as an attribute. (https://developer.husqvarnagroup.cloud/apis/GARDENA+smart+system+API#/swagger )

But py-smart-gardena library's _start_dontoverride function has duration as an argument: _start_dontoverride(self, duration):

Has anyone got this START_DONT_OVERRIDE working using py-smart-gardena library's start_dont_override function? With or without seconds?

crazyfx1 commented 2 years ago

I've already created a PR a month ago to remove the parameter but doesn't seem like it's getting approved soon. https://github.com/py-smart-gardena/py-smart-gardena/pull/122

jlatvala commented 2 years ago

I've already created a PR a month ago to remove the parameter but doesn't seem like it's getting approved soon. py-smart-gardena/py-smart-gardena#122

Maybe it is not approved because the build fails (Python 3.7 fails, 3.6 and 3.8 passes). See https://github.com/py-smart-gardena/py-smart-gardena/pull/122/checks?check_run_id=6251911201 and https://app.travis-ci.com/github/py-smart-gardena/py-smart-gardena/jobs/568802980

crazyfx1 commented 2 years ago

The build error is not related to my change, I guess the 3.7 build is generelly at fault. Other PRs fail aswell with 3.7 and I also don't see how my change can fail in a specific python version.

grm commented 2 years ago

Hello,

I had not realised that this thread was still updated.

@crazyfx1 i'll have a look into you PR tonight ;) Sorry for the delay.