Skip to content

Commit

Permalink
neato/vorwerk: improved user_doc; fixed error message decoding; autom…
Browse files Browse the repository at this point in the history
…atically decode mapID for extraction of boundary IDs. This is needed for single room cleaning
  • Loading branch information
aschwith committed Sep 12, 2023
1 parent 7fcdd77 commit 1d3d7d7
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 40 deletions.
4 changes: 3 additions & 1 deletion neato/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def start_robot(self, boundary_id=None, map_id=None):
response = self.robot.robot_command("start", boundary_id, map_id)
return self.check_command_response(response)

def get_known_mapId(self):
self.logger.warning(f"Debug: MapID is {self.robot.mapId}")
return self.robot.mapId

# returns boundaryIds (clean zones) for given mapID
# returns True on success and False otherwise
Expand All @@ -151,7 +154,6 @@ def dismiss_current_alert(self):
response = self.robot.robot_command("dismiss_current_alert")
return self.check_command_response(response)


# enable cleaning schedule
# returns True on success and False otherwise
def enable_schedule(self):
Expand Down
Binary file added neato/assets/webif2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 47 additions & 3 deletions neato/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,53 @@ item_attributes:
- command_startAvailable
- clean_room

item_structs: NONE
# Definition of item-structure templates for this plugin (enter 'item_structs: NONE', if section should be empty)
#item_structs: NONE
item_structs:
Neato:
Name:
type: str
neato_attribute: 'name'
visu_acl: ro
State:
type: str
value: 'offline'
neato_attribute: 'state'
visu_acl: ro
StateAction:
type: str
neato_attribute: 'state_action'
visu_acl: ro
Command:
type: num
neato_attribute: 'command'
visu_acl: rw
IsDocked:
value: False
type: bool
neato_attribute: 'is_docked'
visu_acl: ro
IsScheduleEnabled:
value: False
type: bool
neato_attribute: 'is_schedule_enabled'
visu_acl: rw
IsCharging:
value: False
type: bool
neato_attribute: 'is_charging'
visu_acl: ro
ChargePercentage:
type: num
neato_attribute: 'charge_percentage'
visu_acl: ro
GoToBaseAvailable:
type: bool
value: False
neato_attribute: 'command_goToBaseAvailable'
visu_acl: ro
Alert:
type: str
neato_attribute: 'alert'
visu_acl: ro

plugin_functions:
enable_schedule:
Expand Down
10 changes: 6 additions & 4 deletions neato/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self, email, password, vendor, token = ''):
self.navigationMode = ''
self.spotWidth = ''
self.spotHeight = ''
self.mapId = 'unknown'

# Meta
self.name = ""
Expand Down Expand Up @@ -158,13 +159,13 @@ def robot_command(self, command, arg1 = None, arg2 = None):
self.logger.warning(f"Command returned {str(responseJson['result'])}: Retry starting with non-persistent-map")
return self.robot_command(command = 'start_non-persistent-map')
else:
self.logger.error("Sending command {command} failed. Result: {0}".format(str(responseJson['result']) ))
self.logger.error("Debug: send command response: {0}".format(start_cleaning_response.text))
self.logger.error(f"Sending command {command} failed. Result: {str(responseJson['result'])}")
self.logger.error(f"Debug: send command response: {start_cleaning_response.text}")
else:
if 'message' in responseJson:
self.logger.error("Sending command {command} failed. Message: {0}".format(str(responseJson['message'])))
self.logger.error(f"Sending command {command} failed. Message: {str(responseJson['message'])}")
if 'error' in responseJson:
self.logger.error("Sending command {command} failed. Error: {0}".format(str(responseJson['error'])))
self.logger.error(f"Sending command {command} failed. Error: {str(responseJson['error'])}")

# - NOT on Charge BASE
return start_cleaning_response
Expand Down Expand Up @@ -286,6 +287,7 @@ def update_robot(self):
self.navigationMode = response['cleaning']['navigationMode']
self.spotWidth = response['cleaning']['spotWidth']
self.spotHeight = response['cleaning']['spotHeight']
self.mapId = response['cleaning']['mapId']

return response

Expand Down
157 changes: 127 additions & 30 deletions neato/user_doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,102 @@ Die Informationen zur Konfiguration des Plugins sind unter :doc:`/plugins_doc/co

Anforderungen
=============
- locale en_US.utf8 must be installed (sudo dpkg-reconfigure locales)

Supported Hardware
==================

=============== ========= ======
Robot Supported Tested
=============== ========= ======
Neato Botvac D3 yes no
Neato Botvac D4 yes no
Neato Botvac D5 yes yes
Neato Botvac D6 yes no
Neato Botvac D7 yes no
Vorwerk VR300 yes yes
=============== ========= ======
1) Es muss auf dem SmarthomeNG Rechcner en_US.utf8 installiert sein (sudo dpkg-reconfigure locales)

Unterstützte Hardware
=====================

=============== ============= ==========
Roboter Unterstützt Getestet
=============== ============= ==========
Neato Botvac D3 ja nein
Neato Botvac D4 ja nein
Neato Botvac D5 ja ja
Neato Botvac D6 ja nein
Neato Botvac D7 ja nein
Vorwerk VR300 ja ja
=============== ============= ==========


Unterstützte Plugin Attribute
=============================

Folgende Item Attribute (neato_attribute) werden vom Plugin unterstützt:

=================== ========= =====================
Attribut Itemtyp Lesend/Schreibend
=================== ========= =====================
name str r
state str r
state_action str r
command num w
is_docked bool r
is_schedule_enabled bool r
is_charging bool r
charge_percentage num r
command_goToBaseAvailable bool r
alert str r
clean_room str w
=================== ========= =====================



Roboter Status
==============

Das String Item für den Roboterstatus (state) kann folgende Zustände einnehmen:

=====================
Roboterstatus (state)
=====================
invalid
invalid
idle
busy
paused
error
===============

Das Num Item für den Roboterzustand (state_action) kann folgende Zustände einnehmen:

============================= =========
Roboterzustand (state_action) dezimal
============================= =========
Invalid 0
House Cleaning 1
Spot Cleaning 2
Manual Cleaning 3
Docking 4
User Menu Active 5
Suspended Cleaning 6
Updating 7
Copying Logs 8
Recovering Location 9
IEC Test 10
Map cleaning 11
Exploring map (creating a persistent map) 12
Acquiring Persistent Map IDs 13
Creating & Uploading Map 14
Suspended Exploration 15
============================= =========

Roboter Befehle
===============

Das Num Item für die Roboterbefehle (command) kann folgende Zustände einnehmen:

============================= =========
Befehl (command) dezimal
============================= =========
Start cleaning 61
Stop cleaning 62
Pause cleaning 63
Resume cleaning 64
Find the robot 65
Send to base 66
Enable schedule 67
Disable schedule 68
============================= =========


Web Interface
Expand Down Expand Up @@ -70,26 +151,42 @@ Im ersten Tab Vorwerk OAuth2 findet sich direkt die Schritt für Schritt Anleitu
.. image:: assets/webif1.jpg
:class: screenshot

Changelog
Im zweiten Tab Einstellungen findet sich zwei Optionen zum Löschen von gemeldeten Alarmmeldungen (z.B. Roboter Behälter leeren) und zum Auslesen aller bekannter RaumIDs (BoundardyIDs) zur
Einzelraumreinigung. Die bekannten Räume werden dazu in das Plugin Logfile geschrieben. Übergeben werden muss hierzu die Vorwerk MapID. Hierzu einmal manuell eine Einzelraumreinigung via Vorwerk/Neato
App anstoßen. Das Plugin extrahiert anschließend automatisch den Namen der MapID und schlägt diese als Eingabe im Eingabefeld des Webinterfaces vor.

.. image:: assets/webif2.jpg
:class: screenshot


SmartVisu
=========

Beispiele
---------
V1.6.8 added decoding of command availability status, e.g. "start" command available
If start command with persistent map is rejected due to "not_on_charge_base" error, retry start with non-persistent map.

V1.6.6 added option to clear errors/alarms in neato/vorwerk backend via plugin's webif
Beispiele für Integrationen in smartVisu:

.. code-block:: html

<p> {{ basic.button('RobotButton_Start', 'Neato.Robot.Command', 'Start', '', '61', 'midi') }} </p>
<p> {{ basic.button('RobotButton_Stop', 'Neato.Robot.Command', 'Stop', '', '62', 'midi') }} </p>
<p> {{ basic.button('RobotButton_Pause', 'Neato.Robot.Command', 'Pause', '', '63', 'midi') }} </p>
<p> {{ basic.button('RobotButton_Resume', 'Neato.Robot.Command', 'Resume', '', '64', 'midi') }} </p>
<p> {{ basic.button('RobotButton_Find', 'Neato.Robot.Command', 'Find', '', '65', 'midi') }}</p>

V1.6.5 added new function start_robot(boundary_id=None, map_id=None) to enable single room cleaning
added new function get_map_boundaries_robot(map_id=None) to request available map boundaries (rooms) for a given map
added new function dismiss_current_alert() to reset current alerts
<p>Name: {{ basic.value('RobotName', 'Neato.Robot.Name') }}</p>
/** Get the robots name (str)*/

V 1.6.4 fixed readout for docking state and go to base availability
combined all neato attribues into one
<p>Cleaning status: {{ basic.value('RobotState', 'Neato.Robot.State') }}</p>
/** Get the robots cleaning status (str) */

V 1.6.3 changed attribute charge_percentage from string to integer
added alert text output, e.g. dustbin full
Write obtained OAuth2 token obtained via web interface directly to config plugin.yaml
<p>Cleaning status action: {{ basic.value('RobotStateAction', 'Neato.Robot.StateAction') }}</p>
/** Get the robots cleaning status action (str). Only when it's busy */

V 1.6.2 Added webinterface
<p>Docking status: {{ basic.value('RobotDockingStatus', 'Neato.Robot.IsDocked') }}</p>
/** Get the robots docking status (bool) */

V 1.6.1 Added new Vorwerk Oauth2 based authentication feature (compatible with myKobold APP)
<p>Battery status: {{ basic.value('RobotBatteryState', 'Neato.Robot.ChargePercentage') }}</p>
/** Get the robots battery charge status (num) */

V 1.6.0 Initial working version
4 changes: 2 additions & 2 deletions neato/webif/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@
{{ _('Verfuegbare Boundary IDs (Raeume) ins Log schreiben') }}
</div>
<div class="col-md-3 mb-3">
<input type="text" class="form-control mb-1" id="input-mapid" placeholder="{{ _('Hier Map ID eintragen') }}" maxlength="25" style="width: 300px;">
<input type="text" class="form-control mb-1" id="input-mapid" placeholder="{{ _('Hier Map ID eintragen') }}" {% if p.get_known_mapId() %} value = {{ p.get_known_mapId() }} {% endif %}
maxlength="25" style="width: 300px;">
</div>

<div class="col-md-6 mb-3">
<button type="button" class="btn btn-shng btn-sm" onclick="listAvailableMaps()" title= "{{ _('Schreibt die verfuegbaren Raeume ins Logfile') }}">{{ _('Liste Raeume') }}</button>
</div>
Expand Down

0 comments on commit 1d3d7d7

Please sign in to comment.