Home

Awesome

pymoebot

A Python library intended to monitor (and control?) the MoeBot robotic lawn mowers.

Goals

History

It was originally intended to utilise the official tuya-iot-python-sdk library but that provided minimal support for the MoeBot. Instead, this library now uses local communication with the MoeBot via the tinytuya library. This does require a little bit of pre-work to identify the LOCAL_KEY for the device so that we can communicate with it.

Regardless of chosen library we are required to have configured a Tuya Cloud project, follow these instructions

Using pymoebot

NOTE: The MoeBot needs to have been activated by adding it to the Tuya/SmartLife app first.

In it's most simplistic use, get an instance of MoeBot, poll for data and then show its attributes.

from pymoebot import MoeBot

moebot = MoeBot('DEVICE_ID', 'IP', 'LOCAL_KEY')
moebot.poll()
print("Battery level: %s%" % moebot.battery)

Alternatively, register as a listener and then start the listening thread on your MoeBot.

from pymoebot import MoeBot

moebot = MoeBot('DEVICE_ID', 'IP', 'LOCAL_KEY')
moebot.add_listener(lambda d: print("Got data: %s", d))
moebot.listen()

# Do some other stuff

moebot.unlisten()

See the examples for further examples of usage.

Communicating with the MoeBot

tinytuya have done all the hard work of communicating with the MoeBot. It is worth sharing my understanding of the specifics about the MoeBot though, since I have made some assumptions and peer-review may be able to identify issues.

The MoeBot (like all other Tuya devices) communicates by way of Tuya Data Points (DPS). Some of these are declared when the mower is queried. Others are provided unsolicited.

import tinytuya

d = tinytuya.Device('DEVICEID', 'DEVICEIP', 'DEVICEKEY')
d.set_version(3.3)
print(d.status())

Will result in:

{'dps': {'6': 100, '101': 'STANDBY', '102': 0, '103': 'MOWER_LEAN', '104': True, '105': 3, '106': 1111, '114': 'AutoMode'}}

Tuya Data Points

DPSRead/WriteValuesComment
6r/w0-100'Battery'
101r<ul><li>STANDBY</li><li>MOWING</li><li>CHARGING</li><li>EMERGENCY</li><li>LOCKED</li><li>PAUSED</li><li>PARK</li><li>CHARGING_WITH_TASK_SUSPEND</li><li>FIXED_MOWING</li><li>ERROR</li></ul>'Machine Status' Provides state - can't seem to command state using this
102r0'Machine error'
103r<ul><li>MOWER_LEAN</li><li>MOWER_EMERGENCY</li><li>MOWER_UI_LOCKED</li><li>NO_LOOP_SIGNAL</li><li>BATTERY_NOT_ENOUGH</li><ul>'Machine warning' Provides sub-states for when the mower is in EMERGENCY
104r/wTrue/False'Rain mode' Should we work in the rain?
105r/w1-99'work time' How many hours to run for when started manually
106r/?1111'machine password'
107wTrue/False'Clear machine appointment' results in a DPS 110 response
108wTrue/False'Query machine appointment' results in a DPS 110 response
109wTrue/False'query partition parameters' results in a DPS 113 response
110r/w[byte data]'Report machine appointment'
111r/?[byte data]'error log'
112r/w[byte data]'work log' Report of mower working time after work has completed, contains last 10 logs
113r/w[byte data]'Partition parameters' specifies the zone mowing configuration
114r/?AutoMode/??'WorkMode'
115w<ul><li>StartMowing</li><li>StartFixedMowing</li><li>PauseWork</li><li>ContinueWork</li><li>CancelWork</li><li>StartReturnStation</li><ul>'Machine Control CMD' used to change mower state

State Model

Main States

The following are the declared states of the MoeBot seen so far. They are signified by a '101' DPS.

EMERGENCY States

The following appear to be sub-states for when the mower is in EMERGENCY state. They are signified by a '103' DPS.

Internals

A Facebook user has opened the main case of the MoeBot and taken photos. Refer to the images captured in the 'internals' folder.