MTrab/landroid_cloud

Zone selection not working

Closed this issue · 18 comments

Describe the issue

Hi,

I think the zone selection is still not working properly. When ich select the zone via the custom Landroid card or directly via the service, It does not change the number from 2 to 1 for instance. Only when I change the number in the official Landroid app let’s say to 100% zone 2 then it is also displayed in the Landroid card. May this has something to do with probabilities that have to be send?

Thanks for your help!

What version of Home Assistant Core has the issue?

Newesr

What was the last working version of Home Assistant Core?

Newest

What version of the Landroid Cloud integration do you have installed

Newest

What type of installation are you running?

Home Assistant OS

Which make and model is the mower used for this integration?

M500

Diagnostics information (NOT log entries!)

None

Relevant log entries

None

Additional information

No response

MTrab commented

This keeps coming up intermittently - NOBODY have shared credentials for me to being able to debug yet.
Without a set of credentials with this issue I cannot debug and perhaps fix it, as I cannot recreate this issue on my mower.

Mail for credentials: landroid_cloud (at) trab.dk

Hi,

thanks for your reply. I'm a little curious about sharing my account credentials. What exactly do you need from the logging so that I could provide this to you as an alternative?

Best!

MTrab commented

I need access to the account so I can test the commands and output.
It's perfectly okay if you are not comfy sharing the account - then it'll just take longer to fix as I'll need access to an account with zones and this issue.

I opened the last issue about this problem, and as you can see in #407, it solved itself. Or maybe it was never a problem. Anyway, I figured out how to test if it works or not. Try this:

  1. Open your HA backend in two browser windows at the same time.
  2. In the first window, navigate to Developer Tools > Template.
  3. Clear everything in the text box and enter the following, but replace YOUR_ENTITY_NAME with the entity name of your mower.
    {{ state_attr("vacuum.YOUR_ENTITY_NAME","zone").current }}
  4. In the second window, navigate to Developer Tools > Services.
  5. Place both windows side by side so that you can see both at the same time.
  6. Run landroid_cloud.setzone and set it to one of your zones.

When you do this, you should see that the "Result type" of the template you entered in step 3 displays the correct zone. If this works, the problem is not with this integration. I double checked that the correct zone has been selected by using the unofficial Landroid DeskApp and it always shows the same zone as the template.

On a side note, I discovered something odd while experimenting with this: You cannot check the state in Developer Tools > States. Somehow it doesn't get updated. Only when using the template you can see the change.

MTrab commented

On a side note, I discovered something odd while experimenting with this: You cannot check the state in Developer Tools > States. Somehow it doesn't get updated. Only when using the template you can see the change.

That's a known issue and I think it's because of the many attributes.

But what you are saying is that this is not an issue after all?

Hi,

thank you. I tried it but it is definitely not working (also checked it in the landroid App and also tried to change the zone propability. Both is not working...

Best

MTrab commented

So - if this IS an issue, I still need credentials. No credentials = No fix.

hi, i am very new here: i will share my credentials with you for WR167E.
What do i have to do?

Hi, can i help you woth the credentials? how can i contact you to send you the credentials?

Mail for credentials: landroid_cloud (at) trab.dk

I have the same problem. Using the instructions above even the internal state of the zone does not change when I run the setzone service.
I am somewhat familiar with Python therefore I can try to debug myself in case I get some instructions.

Using the raw pyworxcloud API setting the zone works perfectly for me: the index array is resorted correctly so that the requested zone is at the current index. However, when I call the service from HA, the array is reset to defaults so that the zone at the current index is always zone 0. Therefore it seems something goes wrong in the HA component before the pyworxcloud API is being called. This is a bit harder to debug, though. How can I enable pyworxcloud debug logs when running in HA?

I have a suspicion what the problem could be: for some reason the internal state of the device.zone["indicies"] array is not up to date in some cases.
The last scheduled status update returned 'indicies': [2, 3, 0, 0, 0, 0, 0, 0, 0, 1]. However, when I set the zone and output the current state right after line https://github.com/MTrab/pyworxcloud/blob/master/pyworxcloud/__init__.py#L909 I get [0, 0, 0, 0, 0, 0, 0, 1, 2, 3]. The same is likely also true for the index. This means the following computation to reorder the array is based on a wrong index (likely 0) and therefore the new array is wrong and a different zone might get selected.

I can confirm that this is indeed the problem. This is the state from the last update:

2024-03-20 15:15:10.798 DEBUG (MainThread) [custom_components.landroid_cloud.device_base] (Horgen, Update signal) Attributes:
{'accessories': None, 'locked': False, 'party_mode_enabled': False, 'torque': 0, 'zone': {'current': 3, 'index': 1, 'indicies': [2, 3, 0, 0, 0, 0, 0, 0, 0, 1], 'starting_point': [11, 47, 55, 60]}, 'supported_landroid_features': 8191, 'api connected': True}

And this is the state in pyworkscloud.setzone a few minutes later:

2024-03-20 15:30:00.026 DEBUG (SyncWorker_0) [pyworxcloud] Current zones: [0, 0, 0, 0, 0, 0, 0, 1, 2, 3]
2024-03-20 15:30:00.030 DEBUG (SyncWorker_0) [pyworxcloud] Current index: 0

@sithmein check my descriptions in #407, I think they are similar. I closed the issue because the problem disappeared, so I thought an update might have fixed it. I no longer use the service, so I'm out of the loop here.

Still need credentials to debug on this error. I have no longer access to any devices setup with zones.

The problem is not related to zones, it's a general problem in pyworxcloud. Here is a log message from an update:
landroid_cloud.log

As you can see, the data received via MQTT (and hence the decoded JSON data) has a timestamp from this afternoon (2024-03-22 13:41:34). This and every other information - such as the zone index (3 in this case)- is also correctly reflected in the HA state. However, the internal _mower still has an old state, as can be seen by the timestamp of 2024-03-21 21:01:13 and the old zone index of 2. I have restarted HA yesterday evening.
It seems the _mower state is read once during start but then never updated. Since setzone uses the mower to create a new DeviceData before it does anything it will always use outdated information. Which results in the problems because the index is wrong. It's not specific to zones, all information is outdated. But setzone is the likely the only (?) operation that relies on up-to-date information therefore you don't notice it otherwise.

Hence you should be able to reproduce and debug without needing access to a different account.

I created a PR for pyworxcloud which fixes the root cause above.