make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.22k stars 489 forks source link

Parkside PMRDA 20-Li A1 reports wrong (or not exhaustive) statuses and incorrect problems #1983

Closed cociweb closed 3 months ago

cociweb commented 3 months ago

Describe the bug Parkside PMRDA 20-Li A1 lawn mower ("type": "moebot_s_mower") sometimes has incorrect mappings in specific cases, and the fault reports always return "Tilted"

To Reproduce Steps to reproduce the behaviour including the device the issue was observed with: use and test the device.

Expected behavior mapping the states and faults correctly (see below)

Additional context correct info is returned from the raw_action attribute of the status but no such attribute for the problems, so individual remapping is not possible. (it would be nice if it is attached as well, but this FR is not the scope of the current ProblemRiport.) Digging deeper, the problem state (103) always return MOWING_LEAN

Only protocol 3.3 is supported.

If the bug involves a device, then please include device diagnostics from mower.txt

Please check if there are messages from Tuya Local in the Home

2024-06-06 11:18:27.269 DEBUG (MainThread) [custom_components.tuya_local.device] Fűnyíró received {"6": 94, "101": "ERROR", "102": 1048576, "103": "MOWER_LEAN", "104": false, "105": 5, "106": **PIN should be REDACTED**, "116": false, "full_poll": true}
2024-06-06 11:18:27.271 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] No mapping for dpid 6 (sensor), unable to determine valid values
2024-06-06 11:18:27.272 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] sensor values: ['Tilted', 'Steep', 'Raining', 'Low battery', 'Weak signal', 'Close top cover', 'Docked', 'Undocked', 'Manually dock', 'Finished fixed mowing', 'Disconnected', 'Paused charging', 'Interrupted', 'Interrupted fixed mowing', 'Turn on button', 'Press start', 'Set 30 minute timer', 'Invalid timer', 'Charging current low', 'Caught in rain', 'Data upload failure', 'Continue', 'Stopped', 'UI locked']
2024-06-06 11:18:27.272 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 103 value from MOWER_LEAN to Tilted
2024-06-06 11:18:27.273 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 103 value from MOWER_LEAN to Tilted
2024-06-06 11:18:27.273 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] sensor values: ['Tilted', 'Steep', 'Raining', 'Low battery', 'Weak signal', 'Close top cover', 'Docked', 'Undocked', 'Manually dock', 'Finished fixed mowing', 'Disconnected', 'Paused charging', 'Interrupted', 'Interrupted fixed mowing', 'Turn on button', 'Press start', 'Set 30 minute timer', 'Invalid timer', 'Charging current low', 'Caught in rain', 'Data upload failure', 'Continue', 'Stopped', 'UI locked']
2024-06-06 11:18:27.277 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from ERROR to error
2024-06-06 11:18:27.278 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from ERROR to error
2024-06-06 11:18:27.280 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] option values: ['Auto', 'Garden']
2024-06-06 11:18:27.281 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 102 value from 1048576 to True
2024-06-06 11:18:27.281 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 102 value from 1048576 to True
2024-06-06 11:18:27.282 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] command values: ['start', 'clean_spot', 'pause', 'stop', 'return_to_base']
2024-06-06 11:18:27.283 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from ERROR to error
2024-06-06 11:18:27.283 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from ERROR to error
2024-06-06 11:18:27.284 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] command values: ['start', 'clean_spot', 'pause', 'stop', 'return_to_base']
2024-06-06 11:18:27.284 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from ERROR to error
2024-06-06 11:18:27.288 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from ERROR to error
2024-06-06 11:18:27.289 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] command values: ['start', 'clean_spot', 'pause', 'stop', 'return_to_base']

....And no unhandled ERROR is raised in python.

make-all commented 3 months ago

Lawn Mower Activity only has the four possible values currently implemented. https://github.com/home-assistant/core/blob/dev/homeassistant/components/lawn_mower/const.py#L6 Because this causes loss of information, the original values are available as the "raw_activity" attribute.

The vacuum entity is for backwards compatibility, as the lawn_mower platform is relatively new (introduced in HA 2023.9, and added to tuya-local in 2024.1.0), so users originally used these devices as vacuums, and the deprecated entity is kept around for some time to allow existing users time to adjust to the new lawn_mower platform.

make-all commented 3 months ago

I have focused on the "MOWER_LEAN is reported all the time" for now, as that is possibly a resolvable issue.

If the device is only reporting this when there is a problem, and otherwise just not reporting anything, it would have become stuck on the last received value. So I have changed the config to mark it as non-persistent, and optional, with a default of "OK" for the case where nothing is received.

cociweb commented 3 months ago

Well, some curious things are happening here. The OK is appeared, but actually the "device still reports" MOWER_LEAN for 103. (it always reports this, independently what is the current / was the last error / or is there any. Everytime is leaning time.. :D) moreover, I've found that state (101) is mapped multiple times with different values. Can it be the primary (lawn_mower) and secondary (vacuum) entities?

2024-06-06 21:27:18.304 DEBUG (MainThread) [custom_components.tuya_local.device] Fűnyíró received {"6": 93, "101": "CHARGING", "102": 0, "103": "MOWER_LEAN", "104": false, "105": 5, "106": $$$$, "116": false, "full_poll": true}
2024-06-06 21:27:18.307 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] command values: ['start', 'clean_spot', 'pause', 'stop', 'return_to_base']
2024-06-06 21:27:18.308 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from CHARGING to charging
2024-06-06 21:27:18.308 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from CHARGING to charging
2024-06-06 21:27:18.309 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] command values: ['start', 'clean_spot', 'pause', 'stop', 'return_to_base']
2024-06-06 21:27:18.309 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from CHARGING to charging
2024-06-06 21:27:18.309 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from CHARGING to charging
2024-06-06 21:27:18.310 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] command values: ['start', 'clean_spot', 'pause', 'stop', 'return_to_base']
2024-06-06 21:27:18.310 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] option values: ['Auto', 'Garden']
2024-06-06 21:27:18.312 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 102 value from 0 to False
2024-06-06 21:27:18.312 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 102 value from 0 to False
2024-06-06 21:27:18.314 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] No mapping for dpid 6 (sensor), unable to determine valid values
2024-06-06 21:27:18.314 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] sensor values: ['OK', 'Tilted', 'Steep', 'Raining', 'Low battery', 'Weak signal', 'Close top cover', 'Docked', 'Undocked', 'Manually dock', 'Finished fixed mowing', 'Disconnected', 'Paused charging', 'Interrupted', 'Interrupted fixed mowing', 'Turn on button', 'Press start', 'Set 30 minute timer', 'Invalid timer', 'Charging current low', 'Caught in rain', 'Data upload failure', 'Continue', 'Stopped', 'UI locked']
2024-06-06 21:27:18.315 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 103 value from MOWER_LEAN to Tilted
2024-06-06 21:27:18.315 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 103 value from MOWER_LEAN to Tilted
2024-06-06 21:27:18.315 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] sensor values: ['OK', 'Tilted', 'Steep', 'Raining', 'Low battery', 'Weak signal', 'Close top cover', 'Docked', 'Undocked', 'Manually dock', 'Finished fixed mowing', 'Disconnected', 'Paused charging', 'Interrupted', 'Interrupted fixed mowing', 'Turn on button', 'Press start', 'Set 30 minute timer', 'Invalid timer', 'Charging current low', 'Caught in rain', 'Data upload failure', 'Continue', 'Stopped', 'UI locked']
2024-06-06 21:27:18.316 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from CHARGING to docked
2024-06-06 21:27:18.316 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Lawnmower: Mapped dps 101 value from CHARGING to docked

image

jonferreira commented 3 months ago

@cociweb did you figured out if/where/how to get notifications from the lawnmower from the rain and "lift" sensors?

Is it DPID 6 that provides these values?

cociweb commented 3 months ago

not yet dpid6 is the battery

jonferreira commented 3 months ago

@make-all what can we do to help make this possible?

cociweb commented 3 months ago

um, I'm afraid, it's not really resolved.

make-all commented 3 months ago

It isn't clear what problem still remains. As explained earlier, most of the "issues" in your original report are not issues at all. If your device is always reporting MOWER_LEAN, then that is an issue with the device. The change included in the previous release was to cover the possibility that it reports nothing when all is OK, but other users have not reported such an issue.

cociweb commented 3 months ago

It isn't clear what problem still remains 1) The status mapping is still wrong, but I accept it if we are waiting for the official HA's implementation (which can be ages) and we don't want to extend them by the custom_component. 2) with correct status and problem and sensor handling we will able to handle correctly the emergency situations. (2 of the requirements are missing here: the correct status and problem handling)

If your device is always reporting MOWER_LEAN, then that is an issue with the device.

It's related with 2. point: then maybe some more feedback is required from other users. I would not state it explicitly, since everywhere (here in this github repo and even in HA's forum) MOWER_LEAN is reported for 103, but nobody identified it as a problem. (there is no report with missing/empty/null or ANY other values) - so maybe there is something behind the scenes, but let's wait for further feedbacks in the discussion of the lawnmower's topic!

Anyways, thank's in advance!

rufik commented 2 months ago

Well, I can confirm that the "problem" sensor always has "Tilted" value. But I've taken close look into this sensor history and found that there are different values but for a very short period, like 0.1 sec - see the screenshot.

image

cociweb commented 1 month ago

@rufik, thank you for highlighting this issue! @make-all, I can confirm that I am experiencing the same behavior, although I had not recognized it before. Do you have any suggestions on how we might address this without using an additional helper?

In the meantime we can reopen the ticket - What do you think?

make-all commented 1 month ago

I don't think it is appropriate to reopen the ticket for a problem with the device itself.

rufik commented 1 month ago

I'll try to enable debug for custom_components.tuya_local and see what's going on with this, maybe I could find some "regularity/pattern" :)

make-all commented 1 month ago

I think most likely you are going to have to ignore the "Tilted" state in any automations. The original Moebot S seems to treat this correctly, only the Parkside seems to use MOWER_LEAN as a default "OK" state (or is missing the sensor and giving false reports about it all the time).

rufik commented 1 month ago

Unfortunetly it looks like DPS 103 (problem sensor) always acts as I wrote - gives us true message for a very short period then changing to kinda "default" state MOWER_LEAN. See the sequence below, when the mower is in stopped-by-red-button state, then I pin-unlocked (cover=open), then moved it (lifted) into another part of garden, pin-unlocked again (cover=open) and started mowing. I can observer some pattern here - everytime I pin-unlock the problem sensor goes into UI locked state for 0.1 sec (blue stripe). Well, when it started mowing you can see "orange stripe" which is "OK" state :)

image

It doesn't look useful for me, time-based patterns are useless for automations/templating as they often bringing race condition problems...maybe DP 103 is misbehaving? Maybe it's just for notification only?

And one more thing - I can see some missing mapping for dpid 6 in logs:

2024-07-18 16:16:19.296 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] No mapping for dpid 6 (sensor), unable to determine valid values
rufik commented 1 month ago

Hmmm, take a close into device abilities (20-Li B2 for me), DPS 101-103:

{
  "abilityId": 101,
  "accessMode": "ro",
  "code": "MachineStatus",
  "description": "\"\"\"待机、充电、割草、暂停、回站、升级、定点割草、错误、自检、充电带工作、急停(增加提示语:请在机器上解除急停)、锁屏\n\n注意:只有待机和充电状态下可以修改APP对应的预约、分区、设置参数,其他状态都不允许修改参数\n\"\"\n\"\n",
  "name": "机器状态",
  "typeSpec": {
    "type": "enum",
    "range": [
      "STANDBY",
      "CHARGING",
      "MOWING",
      "PAUSED",
      "PARK",
      "UPDATA",
      "FIXED_MOWING",
      "ERROR",
      "SELF_TEST",
      "CHARGING_WITH_TASK_SUSPEND",
      "EMERGENCY",
      "LOCKED"
    ]
  }
},

{
  "abilityId": 102,
  "accessMode": "ro",
  "code": "MachineError",
  "description": "\"倾斜小于24、倾斜大于35、无边界信号、左电机堵转、右电机堵转、电池电压高、电池温度异常、放电错误、充电过温、电池损坏、电池电压低、放电过流、放电过温、充电电压低、电池异常需重启,IMU失效、边界传感器失效、雨水失效、霍尔失效、机器倾斜、机器出界、机器提升、机器受困、割草电机故障、机器倾覆、电机过流、电机霍尔错误、电机板通信异常、边界检测通讯异常、电机错误\n\"\n",
  "extensions": {
    "scope": "fault"
  },
  "name": "机器错误",
  "typeSpec": {
    "type": "bitmap",
    "label": [
      "FAULT_LEAN",
      "FAULT_TOO_STEEP",
      "NO_SIGNAL",
      "L_MOTOR_ERROR",
      "R_MOTOR_ERROR",
      "BATTERY_VOL_HIG",
      "B_TEMP_ERROR",
      "DISCHAR_ERROR",
      "CHARGE_OVERTEMP",
      "BATTERY_DAMAGE",
      "BATTERY_LOWDIS",
      "CHARGE_CURDIS",
      "CHARGE_TEMP",
      "UNEXCEPECT_LOW",
      "B_ERROR_RESET",
      "IMU_INVALID",
      "EMS_INVALID",
      "RAIN_INVALID",
      "HALL_INVALID",
      "STEEP_OVER_3S",
      "OUTSIDE_AREA",
      "LIFTED",
      "TRAPPED",
      "B_MOTOR_ERROR",
      "OVERTURN",
      "MOTOR_OVERCUR",
      "MOTOR_HALL",
      "MOTOR_DISCON",
      "EMS_DISCONNECT",
      "MOTOR_ERROR"
    ],
    "maxlen": 30
  }
},

{
  "abilityId": 103,
  "accessMode": "ro",
  "code": "MachineWarning",
  "description": "\"\"\"机器倾斜,请注意机器工作区域、机器倾斜角度偏大,及时关注、正在返回基站避雨中、电量不足,即将开始充电、无信号,请检查边界线是否正常、请关闭盖子,等待机器工作、机器再基站,请把机器移出基站、机器不在基站,请把机器搬到基站、请把机器搬到界内,再次尝试、定点割草工作结束、充电不稳定,请查看充电极是否正常、充电待工作被打断,请查看基站供电是否正常、工作中断,请重新启动工作\n、当前工作终止,请查看周边环境是否正常、请打开物理开关,再次尝试,请按start按键开始,预约时间大于30分钟,预约时间不合法,充电电流低,避雨中,升级失败,继续工作弹框,机器急停,锁屏,放电异常,电池包温度异常\"\"\n\"\n",
  "name": "机器警告",
  "typeSpec": {
    "type": "enum",
    "range": [
      "MOWER_LEAN",
      "MOWER_STEEP",
      "RAIN_PARK",
      "BATTERY_NOT_ENOUGH",
      "NO_LOOP_SIGNAL",
      "CLOSE_TOPCOVER",
      "MOWER_IN_STATION",
      "MOWER_OUT_STATION",
      "PLACE_INSIDE_STATION",
      "FIXED_END",
      "CHARGING_DISCONNECT",
      "CHARGING_PAUSE",
      "WORK_INTERRUPT",
      "FIXED_MOWING_INTERUPT",
      "TURN_ON_BUTTON",
      "PRESS_START_KEY",
      "TIMESET_30MIN",
      "TIMESET_UNLEGAL",
      "CHARGR_CURRENT_LOW",
      "RAIN_OUT_STATION",
      "UPDATA_FAIL",
      "CONTINUE_TOOLTIP",
      "MOWER_EMERGENCY",
      "MOWER_UI_LOCKED",
      "DISCHARGE_ERROR",
      "CHARGE_TEMP_ERROR"
    ]
  }
},

DPS 101 is device state (enum). DPS 102 is device errors list (enum). DPS 103 is device warnings list (enum). Wouldn't it be useful to have all three just exposed in HA as text sensors with raw values? I know 101 is RAW_ACTIVITY property, 103 is a "problem sensor", but 102 is binary_sensor which loses states being mapped.

cociweb commented 1 month ago

ok, I've played a little with the device. it seems, that the problems are reported correctly for less than 1 sec (even if it is really "Tilted" aka lifted). However, every state change of the problem sensor is followed by a new value as "Tilted" state.

@rufik Dpid 6 is the battery. but it maps only for the 2nd attempt. (mapping happens for lawn mower and vacuum types as well - one of them is unsuccessful as I indicated above)

make-all commented 1 month ago

The debug messages about dp6 are not a concern. It is just HA checking if the sensor has fixed values list to see if it should report a warning that it should be an enum.