Skip to content

Commit

Permalink
Add "error" channel
Browse files Browse the repository at this point in the history
Report error codes as strings
  • Loading branch information
Sonic-Amiga committed May 29, 2020
1 parent c086048 commit ec41a86
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 6 deletions.
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ There's no global configuration for this binding.
|---------|--------|----------------------------------------------------|-----------|
| command | String | Command to execute: clean, spot, dock, pause, stop | N |
| cycle | String | Current mission: none, clean, spot | Y |
| phase | String | Current phase of the mission: See below. | Y |
| phase | String | Current phase of the mission; see below. | Y |
| battery | Number | Battery charge in percents | Y |
| bin | String | Bin status: ok, removed, full | Y |
| error | String | Error code; see below | Y |
| rssi | Number | Wi-Fi Received Signal Strength indicator in db | Y |
| snr | Number | Wi-Fi Signal to noise ratio | Y |

Expand All @@ -70,6 +71,67 @@ Known phase strings and their meanings:
Phases, marked with asterisk (*), have not been seen being reported by Roomba 930. All the definitions
are taken from Roomba980-Python.

Error codes. Data type is string in order to be able to utilize mapping to human-readable strings.

| Code | Meaning |
|------|----------------------------|
| 0 | None |
| 1 | Left wheel off floor |
| 2 | Main Brushes stuck |
| 3 | Right wheel off floor |
| 4 | Left wheel stuck |
| 5 | Right wheel stuck |
| 6 | Stuck near a cliff |
| 7 | Left wheel error |
| 8 | Bin error |
| 9 | Bumper stuck |
| 10 | Right wheel error |
| 11 | Bin error |
| 12 | Cliff sensor issue |
| 13 | Both wheels off floor |
| 14 | Bin missing |
| 15 | Reboot required |
| 16 | Bumped unexpectedly |
| 17 | Path blocked |
| 18 | Docking issue |
| 19 | Undocking issue |
| 20 | Docking issue |
| 21 | Navigation problem |
| 22 | Navigation problem |
| 23 | Battery issue |
| 24 | Navigation problem |
| 25 | Reboot required |
| 26 | Vacuum problem |
| 27 | Vacuum problem |
| 29 | Software update needed |
| 30 | Vacuum problem |
| 31 | Reboot required |
| 32 | Smart map problem |
| 33 | Path blocked |
| 34 | Reboot required |
| 35 | Unrecognized cleaning pad |
| 36 | Bin full |
| 37 | Tank needed refilling |
| 38 | Vacuum problem |
| 39 | Reboot required |
| 40 | Navigation problem |
| 41 | Timed out |
| 42 | Localization problem |
| 43 | Navigation problem |
| 44 | Pump issue |
| 45 | Lid open |
| 46 | Low battery |
| 47 | Reboot required |
| 48 | Path blocked |
| 52 | Pad required attention |
| 65 | Hardware problem detected |
| 66 | Low memory |
| 68 | Hardware problem detected |
| 73 | Pad type changed |
| 74 | Max area reached |
| 75 | Navigation problem |
| 76 | Hardware problem detected |

NOTES:

1. Sending "pause" command during missions other than "clean" is equivalent to sending "stop"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class IRobotBindingConstants {
public final static String CHANNEL_PHASE = "phase";
public final static String CHANNEL_BIN = "bin";
public final static String CHANNEL_BATTERY = "battery";
public final static String CHANNEL_ERROR = "error";
public final static String CHANNEL_RSSI = "rssi";
public final static String CHANNEL_SNR = "snr";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,11 @@ public void processMessage(String topic, byte[] payload) {
reportString(CHANNEL_CYCLE, cycle);
reportString(CHANNEL_PHASE, phase);
reportString(CHANNEL_COMMAND, command);
reportString(CHANNEL_ERROR, String.valueOf(missionStatus.getInt("error")));
}

if (reported.has("batPct")) {
reportInt(CHANNEL_BATTERY, reported, "batPct");
reportInt(CHANNEL_BATTERY, reported.getInt("batPct"));
}

if (reported.has("bin")) {
Expand All @@ -312,8 +313,8 @@ public void processMessage(String topic, byte[] payload) {
// {"signal":{"rssi":-55,"snr":33}}
JSONObject signal = reported.getJSONObject("signal");

reportInt(CHANNEL_RSSI, signal, "rssi");
reportInt(CHANNEL_SNR, signal, "snr");
reportInt(CHANNEL_RSSI, signal.getInt("rssi"));
reportInt(CHANNEL_SNR, signal.getInt("snr"));
}

// {"navSwVer":"01.12.01#1","wifiSwVer":"20992","mobilityVer":"5806","bootloaderVer":"4042","umiVer":"6","softwareVer":"v2.4.6-3","tz":{"events":[{"dt":1583082000,"off":180},{"dt":1619884800,"off":180},{"dt":0,"off":0}],"ver":8}}
Expand All @@ -336,8 +337,8 @@ private void reportString(String channel, String str) {
updateState(channel, value);
}

private void reportInt(String channel, JSONObject container, String attr) {
DecimalType value = new DecimalType(container.getInt(attr));
private void reportInt(String channel, int n) {
DecimalType value = new DecimalType(n);

lastState.put(channel, value);
updateState(channel, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<channel id="phase" typeId="phase" />
<channel id="battery" typeId="battery" />
<channel id="bin" typeId="bin" />
<channel id="error" typeId="error" />
<channel id="rssi" typeId="rssi" />
<channel id="snr" typeId="snr" />
</channels>
Expand Down Expand Up @@ -100,6 +101,72 @@
</options>
</state>
</channel-type>
<channel-type id="error">
<item-type>String</item-type>
<label>Error</label>
<description>Error code</description>
<state readOnly="true">
<options>
<!-- Taken from Roomba980-Python, originally reverse engineered from phone app -->
<option value="0">None</option>
<option value="1">Left wheel off floor</option>
<option value="2">Main Brushes stuck</option>
<option value="3">Right wheel off floor</option>
<option value="4">Left wheel stuck</option>
<option value="5">Right wheel stuck</option>
<option value="6">Stuck near a cliff</option>
<option value="7">Left wheel error</option>
<option value="8">Bin error</option>
<option value="9">Bumper stuck</option>
<option value="10">Right wheel error</option>
<option value="11">Bin error</option>
<option value="12">Cliff sensor issue</option>
<option value="13">Both wheels off floor</option>
<option value="14">Bin missing</option>
<option value="15">Reboot required</option>
<option value="16">Bumped unexpectedly</option>
<option value="17">Path blocked</option>
<option value="18">Docking issue</option>
<option value="19">Undocking issue</option>
<option value="20">Docking issue</option>
<option value="21">Navigation problem</option>
<option value="22">Navigation problem</option>
<option value="23">Battery issue</option>
<option value="24">Navigation problem</option>
<option value="25">Reboot required</option>
<option value="26">Vacuum problem</option>
<option value="27">Vacuum problem</option>
<option value="29">Software update needed</option>
<option value="30">Vacuum problem</option>
<option value="31">Reboot required</option>
<option value="32">Smart map problem</option>
<option value="33">Path blocked</option>
<option value="34">Reboot required</option>
<option value="35">Unrecognized cleaning pad</option>
<option value="36">Bin full</option>
<option value="37">Tank needed refilling</option>
<option value="38">Vacuum problem</option>
<option value="39">Reboot required</option>
<option value="40">Navigation problem</option>
<option value="41">Timed out</option>
<option value="42">Localization problem</option>
<option value="43">Navigation problem</option>
<option value="44">Pump issue</option>
<option value="45">Lid open</option>
<option value="46">Low battery</option>
<option value="47">Reboot required</option>
<option value="48">Path blocked</option>
<option value="52">Pad required attention</option>
<option value="65">Hardware problem detected</option>
<option value="66">Low memory</option>
<option value="68">Hardware problem detected</option>
<option value="73">Pad type changed</option>
<option value="74">Max area reached</option>
<option value="75">Navigation problem</option>
<option value="76">Hardware problem detected</option>
</options>
</state>
</channel-type>
<channel-type id="rssi" advanced="true">
<item-type>Number</item-type>
<label>RSSI</label>
Expand Down

0 comments on commit ec41a86

Please sign in to comment.