make-all / tuya-local

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

Moebot S5 functions #1665

Closed stas1000 closed 5 months ago

stas1000 commented 7 months ago

Describe the bug With Tuya Local Moebot S5 integration only the play and pause button seem to work on my HA instance. The cancel mowing button and return to the dock functions do not work.

Expected behavior Through the Tuya App the mower needs to have its job cancelled prior to returning to the dock. With play and pause the only functioning commands the mower would need to complete its scheduled mow prior to returning to the dock

If the bug involves a device, then please include device diagnostics from Settings / Devices & Services / Tuya Local (your device) / "1 device" "integration_manifest": { "domain": "tuya_local", "name": "Tuya Local", "codeowners": [ "@make-all" ], "config_flow": true, "dependencies": [], "documentation": "https://github.com/make-all/tuya-local", "integration_type": "device", "iot_class": "local_push", "issue_tracker": "https://github.com/make-all/tuya-local/issues", "requirements": [ "tinytuya==1.13.1" ], "version": "2024.2.0", "is_built_in": false }, "data": { "name": "Lawnmower", "type": "moebot_s_mower", "device_id": "REDACTED", "device_cid": "", "local_key": "REDACTED", "host": "REDACTED", "protocol_version": 3.4, "tinytuya_version": "1.13.1", "api_version_set": 3.4, "api_version_used": 3.4, "api_working": true, "status": {}, "cached_state": { "updated_at": 1708219689.1643028, "6": 100, "101": "STANDBY", "102": 0, "103": "MOWER_LEAN", "104": true, "105": 8, "106": 1111, "114": "AutoMode", "112": "ZdHpMgAAAQgBZc/3GwAAVEUBZc1UEQAAVFMBZc0dLgAAAI0BZcqxCgAAVFoBZcoy6QAAAJoBZcoNuwAAAOEBZcoMTAAAAWkBZcnecQAAADwBZcndhAAAAOoB" }, "pending_state": {}, "connected": true, "force_dps": [], "home_assistant": { "name": "Lawnmower", "name_by_user": "Lawn mower", "disabled": false, "disabled_by": null, "entities": [ { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": null, "icon": null, "unit_of_measurement": null, "state": { "entity_id": "lawn_mower.lawn_mower", "state": "docked", "attributes": { "raw_activity": "STANDBY", "error": 0, "password": 1111, "work_log": "ZdHpMgAAAQgBZc/3GwAAVEUBZc1UEQAAVFMBZc0dLgAAAI0BZcqxCgAAVFoBZcoy6QAAAJoBZcoNuwAAAOEBZcoMTAAAAWkBZcnecQAAADwBZcndhAAAAOoB", "auto_mode": "AutoMode", "friendly_name": "Lawn mower", "supported_features": 7 }, "last_changed": "2024-02-18T01:02:58.529455+00:00", "last_updated": "2024-02-18T01:19:24.732602+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": "battery", "icon": null, "unit_of_measurement": "%", "state": { "entity_id": "sensor.lawn_mower_battery", "state": "100", "attributes": { "state_class": "measurement", "unit_of_measurement": "%", "device_class": "battery", "friendly_name": "Lawn mower Battery" }, "last_changed": "2024-02-18T00:59:29.753717+00:00", "last_updated": "2024-02-18T00:59:29.753717+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": null, "icon": null, "unit_of_measurement": null, "state": { "entity_id": "button.lawn_mower_cancel_mowing", "state": "2024-02-18T00:59:33.343681+00:00", "attributes": { "icon": "mdi:mower", "friendly_name": "Lawn mower Cancel mowing" }, "last_changed": "2024-02-18T00:59:33.344046+00:00", "last_updated": "2024-02-18T00:59:33.344046+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "config", "device_class": null, "original_device_class": null, "icon": null, "unit_of_measurement": null, "state": { "entity_id": "button.lawn_mower_clear_schedule", "state": "unknown", "attributes": { "icon": "mdi:calendar-remove", "friendly_name": "Lawn mower Clear schedule" }, "last_changed": "2024-02-18T00:59:29.751910+00:00", "last_updated": "2024-02-18T00:59:29.751910+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "diagnostic", "device_class": null, "original_device_class": "problem", "icon": null, "unit_of_measurement": null, "state": { "entity_id": "binary_sensor.lawn_mower_error", "state": "off", "attributes": { "device_class": "problem", "friendly_name": "Lawn mower Error" }, "last_changed": "2024-02-18T00:59:29.750411+00:00", "last_updated": "2024-02-18T00:59:29.750411+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "diagnostic", "device_class": null, "original_device_class": "enum", "icon": null, "unit_of_measurement": null, "state": { "entity_id": "sensor.lawn_mower_problem", "state": "Tilted", "attributes": { "options": [ "Tilted", "Stopped", "UI locked", "Weak signal", "Low battery", "Charging interrupted", "Raining" ], "device_class": "enum", "icon": "mdi:robot-mower-outline", "friendly_name": "Lawn mower Problem" }, "last_changed": "2024-02-18T00:59:29.754049+00:00", "last_updated": "2024-02-18T00:59:29.754049+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "config", "device_class": null, "original_device_class": null, "icon": null, "unit_of_measurement": null, "state": { "entity_id": "button.lawn_mower_query_schedule", "state": "2024-02-12T04:34:27.310928+00:00", "attributes": { "icon": "mdi:calendar-refresh", "friendly_name": "Lawn mower Query schedule" }, "last_changed": "2024-02-18T00:59:29.752137+00:00", "last_updated": "2024-02-18T00:59:29.752137+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "config", "device_class": null, "original_device_class": null, "icon": null, "unit_of_measurement": null, "state": { "entity_id": "button.lawn_mower_query_zones", "state": "unknown", "attributes": { "icon": "mdi:map-search", "friendly_name": "Lawn mower Query zones" }, "last_changed": "2024-02-18T00:59:29.752348+00:00", "last_updated": "2024-02-18T00:59:29.752348+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "config", "device_class": null, "original_device_class": "switch", "icon": null, "unit_of_measurement": null, "state": { "entity_id": "switch.lawn_mower_rain_mode", "state": "on", "attributes": { "device_class": "switch", "icon": "mdi:weather-pouring", "friendly_name": "Lawn mower Rain mode" }, "last_changed": "2024-02-18T00:59:29.753402+00:00", "last_updated": "2024-02-18T00:59:29.753402+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "config", "device_class": null, "original_device_class": null, "icon": null, "unit_of_measurement": "h", "state": { "entity_id": "number.lawn_mower_running_time", "state": "8", "attributes": { "min": 1, "max": 24, "step": 1.0, "mode": "auto", "unit_of_measurement": "h", "icon": "mdi:clock", "friendly_name": "Lawn mower Running time" }, "last_changed": "2024-02-18T00:59:29.751047+00:00", "last_updated": "2024-02-18T00:59:29.751047+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": null, "icon": null, "unit_of_measurement": null, "state": { "entity_id": "button.lawn_mower_start_fixed_mowing", "state": "2024-02-14T09:38:59.997317+00:00", "attributes": { "icon": "mdi:mower-on", "friendly_name": "Lawn mower Start fixed mowing" }, "last_changed": "2024-02-18T00:59:29.751393+00:00", "last_updated": "2024-02-18T00:59:29.751393+00:00" } }, { "disabled": true, "disabled_by": "integration", "entity_category": null, "device_class": null, "original_device_class": null, "icon": null, "unit_of_measurement": null, "state": null } ] } } }

Please check if there are messages from Tuya Local in the Home This error originated from a custom integration.

Logger: custom_components.tuya_local.helpers.config Source: custom_components/tuya_local/helpers/config.py:46 Integration: Tuya Local (documentation, issues) First occurred: 03:11:42 (2 occurrences) Last logged: 11:29:29

The use of vacuum for Lawnmower is deprecated and should be replaced by lawn_mower.

make-all commented 7 months ago

This is possibly a new device, as the supported model is S20 not S5, and it seems the feature set is slightly different.

Aree you able to access the QueryThingsDataModel cloud API result from iot.tuya.com? This should have the full details for this model

stas1000 commented 6 months ago

Ohh i assumed they would be the same controls. bummer! This is the this is the result of the things data model:

{ "result": { "model": "{\"modelId\":\"000002cyrx\",\"services\":[{\"actions\":[],\"code\":\"\",\"description\":\"\",\"events\":[],\"name\":\"默认服务\",\"properties\":[{\"abilityId\":6,\"accessMode\":\"rw\",\"code\":\"battery_percentage\",\"description\":\"电量只需要上报,不需要下发\",\"extensions\":{\"attribute\":\"128\"},\"name\":\"剩余电量\",\"typeSpec\":{\"max\":100,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"%\"}},{\"abilityId\":101,\"accessMode\":\"rw\",\"code\":\"MachineStatus\",\"description\":\"\",\"name\":\"机器状态\",\"typeSpec\":{\"range\":[\"STANDBY\",\"CHARGING\",\"MOWING\",\"PAUSED\",\"PARK\",\"UPDATA\",\"FIXED_MOWING\",\"ERROR\",\"SELF_TEST\",\"CHARGING_WITH_TASK_SUSPEND\",\"EMERGENCY\",\"LOCKED\"],\"type\":\"enum\",\"typeDefaultValue\":\"STANDBY\"}},{\"abilityId\":102,\"accessMode\":\"ro\",\"code\":\"MachineError\",\"description\":\"\",\"extensions\":{\"scope\":\"fault\"},\"name\":\"机器错误\",\"typeSpec\":{\"label\":[\"FAULT_LEAN\",\"FAULT_TOO_STEEP\",\"NO_SIGNAL\",\"L_MOTOR_ERROR\",\"R_MOTOR_ERROR\",\"BATTERY_VOL_HIG\",\"CHARGE_OVERCUR\",\"CHARGE_OVERVOL\",\"CHARGE_OVERTEMP\",\"BATTERY_DAMAGE\",\"BATTERY_LOW\",\"DISCHARGE_CUR\",\"DISCHARGE_TEMP\",\"UNEXCEPECT_LOW\",\"EXCEPECT_ERROR\",\"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,\"type\":\"bitmap\",\"typeDefaultValue\":0}},{\"abilityId\":103,\"accessMode\":\"ro\",\"code\":\"MachineWarning\",\"description\":\"\",\"name\":\"机器警告\",\"typeSpec\":{\"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\"],\"type\":\"enum\",\"typeDefaultValue\":\"MOWER_LEAN\"}},{\"abilityId\":104,\"accessMode\":\"rw\",\"code\":\"MachineRainMode\",\"description\":\"0为关\n1 为开\",\"name\":\"雨水开关\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},{\"abilityId\":105,\"accessMode\":\"rw\",\"code\":\"MachineWorktime\",\"description\":\"\",\"name\":\"工作时长\",\"typeSpec\":{\"max\":99,\"min\":1,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":1,\"unit\":\"小时\"}},{\"abilityId\":106,\"accessMode\":\"ro\",\"code\":\"MachinePassword\",\"description\":\"\",\"name\":\"机器密码\",\"typeSpec\":{\"max\":4444,\"min\":1111,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":1111,\"unit\":\"\"}},{\"abilityId\":107,\"accessMode\":\"wr\",\"code\":\"ClearAppointment\",\"description\":\"\",\"name\":\"清空机器预约\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},{\"abilityId\":108,\"accessMode\":\"wr\",\"code\":\"QueryAppointment\",\"description\":\"\",\"name\":\"查询机器预约\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},{\"abilityId\":109,\"accessMode\":\"wr\",\"code\":\"QueryPartition\",\"description\":\"\",\"name\":\"查询分区参数\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},{\"abilityId\":110,\"accessMode\":\"rw\",\"code\":\"MachineAppointment\",\"description\":\"\",\"name\":\"上报机器预约\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}},{\"abilityId\":111,\"accessMode\":\"ro\",\"code\":\"MachineErrorLog\",\"description\":\"\",\"name\":\"错误日志\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}},{\"abilityId\":112,\"accessMode\":\"ro\",\"code\":\"MachineWorkLog\",\"description\":\"\",\"name\":\"工作日志\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}},{\"abilityId\":113,\"accessMode\":\"rw\",\"code\":\"MachinePartition\",\"description\":\"\",\"name\":\"分区参数\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}},{\"abilityId\":114,\"accessMode\":\"rw\",\"code\":\"MachineWorkMode\",\"description\":\"\",\"name\":\"工作模式\",\"typeSpec\":{\"range\":[\"AutoMode\",\"GardenMode\"],\"type\":\"enum\",\"typeDefaultValue\":\"AutoMode\"}},{\"abilityId\":115,\"accessMode\":\"wr\",\"code\":\"MachineControlCmd\",\"description\":\"\",\"name\":\"机器控制指令\",\"typeSpec\":{\"range\":[\"PauseWork\",\"CancelWork\",\"ContinueWork\",\"StartMowing\",\"StartFixedMowing\",\"StartReturnStation\"],\"type\":\"enum\",\"typeDefaultValue\":\"PauseWork\"}}]}]}" }, "success": true, "t": 1708291540342, "tid": "43c4abcacea411ee9d7cfe8b4d072f7e" }

stas1000 commented 6 months ago

Also the query properties:

{ "result": { "properties": [ { "code": "battery_percentage", "custom_name": "", "dp_id": 6, "time": 1708261131832, "value": 100 }, { "code": "MachineStatus", "custom_name": "", "dp_id": 101, "time": 1708262291841, "value": "STANDBY" }, { "code": "MachineError", "custom_name": "", "dp_id": 102, "time": 1707903737449, "value": 0 }, { "code": "MachineWarning", "custom_name": "", "dp_id": 103, "time": 1707903744755, "value": "MOWER_LEAN" }, { "code": "MachineRainMode", "custom_name": "", "dp_id": 104, "time": 1707689483468, "value": true }, { "code": "MachineWorktime", "custom_name": "", "dp_id": 105, "time": 1707689483477, "value": 8 }, { "code": "MachinePassword", "custom_name": "", "dp_id": 106, "time": 1707689483487, "value": 1111 }, { "code": "ClearAppointment", "custom_name": "", "dp_id": 107, "time": 1669441188171, "value": false }, { "code": "QueryAppointment", "custom_name": "", "dp_id": 108, "time": 1669441188171, "value": false }, { "code": "QueryPartition", "custom_name": "", "dp_id": 109, "time": 1669441188171, "value": false }, { "code": "MachineAppointment", "custom_name": "", "dp_id": 110, "time": 1708241265173, "value": "AIiIiIgBiIiIiAIAAAYAA4iIiIgEAAAGAAWIiIiIBgAABgA=" }, { "code": "MachineErrorLog", "custom_name": "", "dp_id": 111, "time": 1708086637925, "value": "Zc0duhRlyg6bFGXJ2i4CZcnZtQJlydmgAmXJ2XMCZcnYMgIAAAAAAAAAAAAAAAAAAAA=" }, { "code": "MachineWorkLog", "custom_name": "", "dp_id": 112, "time": 1708256671253, "value": "ZdIQwgAAcIIBZdHpMgAAAQgBZc/3GwAAVEUBZc1UEQAAVFMBZc0dLgAAAI0BZcqxCgAAVFoBZcoy6QAAAJoBZcoNuwAAAOEBZcoMTAAAAWkBZcnecQAAADwB" }, { "code": "MachinePartition", "custom_name": "", "dp_id": 113, "time": 1708241265467, "value": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" }, { "code": "MachineWorkMode", "custom_name": "", "dp_id": 114, "time": 1707689484567, "value": "AutoMode" }, { "code": "MachineControlCmd", "custom_name": "", "dp_id": 115, "time": 1669441188171, "value": "PauseWork" } ] }, "success": true, "t": 1708291997077, "tid": "540d8798cea511ee99065aa890dc07f7" }

make-all commented 6 months ago

After more thorough review, the dps are the same as S20, but some additional commands (continue) and statuses are in the full docs you provided, so the config has been improved with these.

There was an issue with the additional command buttons using the wrong type, so that may now be fixed. Unfortunately the lawn_mower platform is very basic, with only 3 commands supported, and it isn't possible to have it perform a sequence of commands without custom code that may not be relevant to other mowers. But now that the Cancel button should be working, you can perform the same sequence as the app, just outside the lawn_mower entity.

stas1000 commented 6 months ago

I'll try copying over the code, removing the mower, restart home assistant & re add the device

stas1000 commented 6 months ago

Thanks Mate, I can confirm play, pause, cancel and dock now work with that update