iRobot Roomba 980 integration

Moderator: leecollings

Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by Filip »

It is in the procedure in the readme on GitHub
manuloup
Posts: 31
Joined: Sunday 23 November 2014 16:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: iRobot Roomba 980 integration

Post by manuloup »

which part ?
Rapberry PI B+ (RaspBian), RFXtrx433E USB 433.92MHz Transceiver, AEON LABS Controler Z-Wave, Aeon Labs Z-Stick S2, Everspring ST814 Temperature Sensor, Everspring SF812 Smoke Detector, 2x Fibaro Wallplug, Aeon Zwave Miniremote , Xbee Teleinfo USB
Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by Filip »

About the config.ini.
Extract of text:
run python3 ./roomba/getpassword.py -R ROOMBA_IP and follow the instructions. Shortly the vacuum cleaner must be docked and you need to HOLD the HOME button for some seconds until a sound is played (the WIFI indicator on the ROOMBA will flash).
If all went well, there should be a config.ini file in the folder /home/pi/domoticz/plugins/Roomba/. You can check the content with cat config.ini and will find the ROOMBA_IP, blid, password and some other data about the ROOMBA vaccum cleaner.
manuloup
Posts: 31
Joined: Sunday 23 November 2014 16:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: iRobot Roomba 980 integration

Post by manuloup »

Yes, but it comes after the start of the service, which will fail because the config file does not exist yet.
Rapberry PI B+ (RaspBian), RFXtrx433E USB 433.92MHz Transceiver, AEON LABS Controler Z-Wave, Aeon Labs Z-Stick S2, Everspring ST814 Temperature Sensor, Everspring SF812 Smoke Detector, 2x Fibaro Wallplug, Aeon Zwave Miniremote , Xbee Teleinfo USB
Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by Filip »

Hi,
Thanks for the information and you are totally right (of course). I change both steps in the procedure.
Filip
manuloup
Posts: 31
Joined: Sunday 23 November 2014 16:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: France
Contact:

Re: iRobot Roomba 980 integration

Post by manuloup »

No problem Filip. Just wanted to give you my return because I followed the procedure.

Anyway, that is a good job and the plugin is working well. Thanks for all.
Rapberry PI B+ (RaspBian), RFXtrx433E USB 433.92MHz Transceiver, AEON LABS Controler Z-Wave, Aeon Labs Z-Stick S2, Everspring ST814 Temperature Sensor, Everspring SF812 Smoke Detector, 2x Fibaro Wallplug, Aeon Zwave Miniremote , Xbee Teleinfo USB
Svennie
Posts: 13
Joined: Sunday 25 October 2020 14:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Helmond
Contact:

Re: iRobot Roomba 980 integration

Post by Svennie »

Filip wrote: Sunday 17 January 2021 11:21 I made a plugin for the ROOMBA i7... Don't know if it works with the Roomba 980 however would be interesting if somebody can give it a try and give feedback. The plugin is available on https://github.com/FilipDem/Domoticz-iR ... MBA-plugin.
Hello Filip,

I installed your Roomba Plugin. I think I did everything correct. But I get the following error in Domoticz, can you tell me what I'm doing wrong?:

2021-01-24 11:21:00.442 Error: EventSystem: in Staat Lydia: [string "commandArray = {}..."]:3: attempt to index a nil value (global 'devicechanged')

Thank you for your help in advance.

Greetz Sven
Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by Filip »

Seems strange as the error seems to come from the LUA framework while I am not using this in the plugin.
What is Staat Lydia? This is a device I suppose... Did you rename the generated Roomba devices that we're created automatically? This could be the problem...
If necessity you need to activate the debug mode of the plugin and post the relevant traces.
Svennie
Posts: 13
Joined: Sunday 25 October 2020 14:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Helmond
Contact:

Re: iRobot Roomba 980 integration

Post by Svennie »

Filip wrote: Sunday 24 January 2021 15:20 Seems strange as the error seems to come from the LUA framework while I am not using this in the plugin.
What is Staat Lydia? This is a device I suppose... Did you rename the generated Roomba devices that we're created automatically? This could be the problem...
If necessity you need to activate the debug mode of the plugin and post the relevant traces.
Filip,

Lydia is de name of my Roomba. Cloud it be that Domoticz is translating to Dutch in de log-file? State translated to Dutch is Staat. And no I didn't rename the device that had been created.

I activated the debug mode. see below for the result:

pi@raspberrypi:~/domoticz/plugins/Roomba $ python3 mqtt_Roomba.py -D 3
CV or numpy module not found, falling back to PIL
<CTRL C> to exit
Subscribe to /roomba/feedback/# to see published data
Broker Connected with result code 0
Broker Subscribed: 1 (0,)
Broker Subscribed: 2 (0,)
^CSystem exit Received - Exiting program
Broker disconnected

Can you make anything out of it. I'm going to install your plugin on my other Rpi. Maybe the other Raspberry is nog functioning correct. Keep me posted on what you think.
Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by Filip »

Svennie wrote: Sunday 24 January 2021 19:34
Filip wrote: Sunday 24 January 2021 15:20 Seems strange as the error seems to come from the LUA framework while I am not using this in the plugin.
What is Staat Lydia? This is a device I suppose... Did you rename the generated Roomba devices that we're created automatically? This could be the problem...
If necessity you need to activate the debug mode of the plugin and post the relevant traces.
Filip,

Lydia is de name of my Roomba. Cloud it be that Domoticz is translating to Dutch in de log-file? State translated to Dutch is Staat. And no I didn't rename the device that had been created.

I activated the debug mode. see below for the result:

pi@raspberrypi:~/domoticz/plugins/Roomba $ python3 mqtt_Roomba.py -D 3
CV or numpy module not found, falling back to PIL
<CTRL C> to exit
Subscribe to /roomba/feedback/# to see published data
Broker Connected with result code 0
Broker Subscribed: 1 (0,)
Broker Subscribed: 2 (0,)
^CSystem exit Received - Exiting program
Broker disconnected

Can you make anything out of it. I'm going to install your plugin on my other Rpi. Maybe the other Raspberry is nog functioning correct. Keep me posted on what you think.
Seems that this is indeed working well. I give some information that I posted to help somebody else on https://github.com/FilipDem/Domoticz-iR ... n/issues/2. Especially the test with mosquitto_sub is interesting to do.

mqtt_Roomba.py connects to the ROOMBA and publishes (MQTT PUB) ROOMBA data to the mosquitto (MQTT brooker). The domoticz plugin (plugin.py) is the MQTT client/subscriber.

Check if mosquitto is really running. All is based on 'localhost' so be sure it is running on the same machine as your domoticz. You can check it with sudo service mosquitto status. I suppose it will be the case seen the domoticz client can connect (otherwise I would have seen an error message in the log). I am rather sure it is between the ROOMBA and domoticz.

Be sure that mqtt_Roomba.py is also running. If you start it manually, be sure that at every reboot it is started. If you created a service (as indicated in the procedure, check if the service is running with sudo service roomba status.

You can test without domoticz by starting a MQTT subscriber manually. If you run mosquitto_sub -v -t /roomba/feedback/# (again on the same machine), you should receive the raw output that is sent regularly by ROOMBA. Output should be something like:

/roomba/feedback/netinfo_dhcp True
/roomba/feedback/netinfo_addr 3232261301
/roomba/feedback/netinfo_mask 4294967040
/roomba/feedback/netinfo_gw 3232261121
/roomba/feedback/netinfo_dns1 3232261121
/roomba/feedback/netinfo_dns2 0
/roomba/feedback/netinfo_bssid 6c:b0:ce:14:2f:cd
/roomba/feedback/netinfo_sec 4
/roomba/feedback/wifistat_wifi 1
/roomba/feedback/wifistat_uap False
/roomba/feedback/wifistat_cloud 1
/roomba/feedback/netinfo_dhcp True
... (deleted a part)
/roomba/feedback/bbsys_hr 517
/roomba/feedback/bbsys_min 57
/roomba/feedback/state Charging
/roomba/feedback/signal_rssi -35
/roomba/feedback/signal_snr 54
/roomba/feedback/state Charging
/roomba/feedback/signal_rssi -36
/roomba/feedback/signal_snr 53
/roomba/feedback/state Charging
If you don't have this, it will certainly not work in Domoticz.
Hope it helps. Success
Svennie
Posts: 13
Joined: Sunday 25 October 2020 14:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Helmond
Contact:

Re: iRobot Roomba 980 integration

Post by Svennie »

Filip wrote: Monday 25 January 2021 8:45
Svennie wrote: Sunday 24 January 2021 19:34
Filip wrote: Sunday 24 January 2021 15:20 Seems strange as the error seems to come from the LUA framework while I am not using this in the plugin.
What is Staat Lydia? This is a device I suppose... Did you rename the generated Roomba devices that we're created automatically? This could be the problem...
If necessity you need to activate the debug mode of the plugin and post the relevant traces.
Filip,

Lydia is de name of my Roomba. Cloud it be that Domoticz is translating to Dutch in de log-file? State translated to Dutch is Staat. And no I didn't rename the device that had been created.

I activated the debug mode. see below for the result:

pi@raspberrypi:~/domoticz/plugins/Roomba $ python3 mqtt_Roomba.py -D 3
CV or numpy module not found, falling back to PIL
<CTRL C> to exit
Subscribe to /roomba/feedback/# to see published data
Broker Connected with result code 0
Broker Subscribed: 1 (0,)
Broker Subscribed: 2 (0,)
^CSystem exit Received - Exiting program
Broker disconnected

Can you make anything out of it. I'm going to install your plugin on my other Rpi. Maybe the other Raspberry is nog functioning correct. Keep me posted on what you think.
Seems that this is indeed working well. I give some information that I posted to help somebody else on https://github.com/FilipDem/Domoticz-iR ... n/issues/2. Especially the test with mosquitto_sub is interesting to do.

mqtt_Roomba.py connects to the ROOMBA and publishes (MQTT PUB) ROOMBA data to the mosquitto (MQTT brooker). The domoticz plugin (plugin.py) is the MQTT client/subscriber.

Check if mosquitto is really running. All is based on 'localhost' so be sure it is running on the same machine as your domoticz. You can check it with sudo service mosquitto status. I suppose it will be the case seen the domoticz client can connect (otherwise I would have seen an error message in the log). I am rather sure it is between the ROOMBA and domoticz.

Be sure that mqtt_Roomba.py is also running. If you start it manually, be sure that at every reboot it is started. If you created a service (as indicated in the procedure, check if the service is running with sudo service roomba status.

You can test without domoticz by starting a MQTT subscriber manually. If you run mosquitto_sub -v -t /roomba/feedback/# (again on the same machine), you should receive the raw output that is sent regularly by ROOMBA. Output should be something like:

/roomba/feedback/netinfo_dhcp True
/roomba/feedback/netinfo_addr 3232261301
/roomba/feedback/netinfo_mask 4294967040
/roomba/feedback/netinfo_gw 3232261121
/roomba/feedback/netinfo_dns1 3232261121
/roomba/feedback/netinfo_dns2 0
/roomba/feedback/netinfo_bssid 6c:b0:ce:14:2f:cd
/roomba/feedback/netinfo_sec 4
/roomba/feedback/wifistat_wifi 1
/roomba/feedback/wifistat_uap False
/roomba/feedback/wifistat_cloud 1
/roomba/feedback/netinfo_dhcp True
... (deleted a part)
/roomba/feedback/bbsys_hr 517
/roomba/feedback/bbsys_min 57
/roomba/feedback/state Charging
/roomba/feedback/signal_rssi -35
/roomba/feedback/signal_snr 54
/roomba/feedback/state Charging
/roomba/feedback/signal_rssi -36
/roomba/feedback/signal_snr 53
/roomba/feedback/state Charging
If you don't have this, it will certainly not work in Domoticz.
Hope it helps. Success
Flilip,

I did run de command you gave me. I didn't get any result on my Rpi4. So I try to install your plug-in on a RPi3 with Domoticz. It worked on that one. Thnx for you help. Eventually I wanna run Domoticz with your plugin on the Rpi4. So now I know what the do. It does do what I needed. Now I have the get some scripts running what turning on my lights so my Roomba can vacuum at night.

greetz Sven
Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by Filip »

Svennie wrote: Tuesday 26 January 2021 18:20
Filip wrote: Monday 25 January 2021 8:45
Svennie wrote: Sunday 24 January 2021 19:34

Filip,

Lydia is de name of my Roomba. Cloud it be that Domoticz is translating to Dutch in de log-file? State translated to Dutch is Staat. And no I didn't rename the device that had been created.

I activated the debug mode. see below for the result:

pi@raspberrypi:~/domoticz/plugins/Roomba $ python3 mqtt_Roomba.py -D 3
CV or numpy module not found, falling back to PIL
<CTRL C> to exit
Subscribe to /roomba/feedback/# to see published data
Broker Connected with result code 0
Broker Subscribed: 1 (0,)
Broker Subscribed: 2 (0,)
^CSystem exit Received - Exiting program
Broker disconnected

Can you make anything out of it. I'm going to install your plugin on my other Rpi. Maybe the other Raspberry is nog functioning correct. Keep me posted on what you think.
Seems that this is indeed working well. I give some information that I posted to help somebody else on https://github.com/FilipDem/Domoticz-iR ... n/issues/2. Especially the test with mosquitto_sub is interesting to do.

mqtt_Roomba.py connects to the ROOMBA and publishes (MQTT PUB) ROOMBA data to the mosquitto (MQTT brooker). The domoticz plugin (plugin.py) is the MQTT client/subscriber.

Check if mosquitto is really running. All is based on 'localhost' so be sure it is running on the same machine as your domoticz. You can check it with sudo service mosquitto status. I suppose it will be the case seen the domoticz client can connect (otherwise I would have seen an error message in the log). I am rather sure it is between the ROOMBA and domoticz.

Be sure that mqtt_Roomba.py is also running. If you start it manually, be sure that at every reboot it is started. If you created a service (as indicated in the procedure, check if the service is running with sudo service roomba status.

You can test without domoticz by starting a MQTT subscriber manually. If you run mosquitto_sub -v -t /roomba/feedback/# (again on the same machine), you should receive the raw output that is sent regularly by ROOMBA. Output should be something like:

/roomba/feedback/netinfo_dhcp True
/roomba/feedback/netinfo_addr 3232261301
/roomba/feedback/netinfo_mask 4294967040
/roomba/feedback/netinfo_gw 3232261121
/roomba/feedback/netinfo_dns1 3232261121
/roomba/feedback/netinfo_dns2 0
/roomba/feedback/netinfo_bssid 6c:b0:ce:14:2f:cd
/roomba/feedback/netinfo_sec 4
/roomba/feedback/wifistat_wifi 1
/roomba/feedback/wifistat_uap False
/roomba/feedback/wifistat_cloud 1
/roomba/feedback/netinfo_dhcp True
... (deleted a part)
/roomba/feedback/bbsys_hr 517
/roomba/feedback/bbsys_min 57
/roomba/feedback/state Charging
/roomba/feedback/signal_rssi -35
/roomba/feedback/signal_snr 54
/roomba/feedback/state Charging
/roomba/feedback/signal_rssi -36
/roomba/feedback/signal_snr 53
/roomba/feedback/state Charging
If you don't have this, it will certainly not work in Domoticz.
Hope it helps. Success
Flilip,

I did run de command you gave me. I didn't get any result on my Rpi4. So I try to install your plug-in on a RPi3 with Domoticz. It worked on that one. Thnx for you help. Eventually I wanna run Domoticz with your plugin on the Rpi4. So now I know what the do. It does do what I needed. Now I have the get some scripts running what turning on my lights so my Roomba can vacuum at night.

greetz Sven
Happy with your feedback and glad it works!
Svennie
Posts: 13
Joined: Sunday 25 October 2020 14:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Helmond
Contact:

Re: iRobot Roomba 980 integration

Post by Svennie »

Filip,

I encountered an issue. The Plugin works great. But... after 10, 30, 60 or 2 hours the plugin isn't updating the status of my Roomba S9.
Even do my Roomba is running.

When u run the command: sudo service roomba status, I get the following.

pi@raspberrypi:~ $ sudo service roomba status
● roomba.service - Roomba mqtt client
Loaded: loaded (/etc/systemd/system/roomba.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2021-01-27 18:11:53 CET; 31min ago
Main PID: 3233 (python3)
Tasks: 1 (limit: 2182)
CGroup: /system.slice/roomba.service
└─3233 /usr/bin/python3 /home/pi/domoticz/plugins/Roomba/mqtt_Roomba.py

So de service is running. But there is no change in Domoticz. But when I run "sudo service roomba stop" and then "Sudo service roomba start" or I run "Sudo service roomba restart" the status in Domoticz is updatet after a couple of seconds.

In a couple of post earlier you gave me a command to run to test the response of the Roomba. "mosquitto_sub -v -t /roomba/feedback/#" When my Roomba is running it gives a response. That stops when he is on his dock and charging.

Can I do anything to keep the roomba service sort of alive?

Thank you again for your help.
Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by Filip »

Svennie wrote: Wednesday 27 January 2021 21:34 Filip,

I encountered an issue. The Plugin works great. But... after 10, 30, 60 or 2 hours the plugin isn't updating the status of my Roomba S9.
Even do my Roomba is running.

When u run the command: sudo service roomba status, I get the following.

pi@raspberrypi:~ $ sudo service roomba status
● roomba.service - Roomba mqtt client
Loaded: loaded (/etc/systemd/system/roomba.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2021-01-27 18:11:53 CET; 31min ago
Main PID: 3233 (python3)
Tasks: 1 (limit: 2182)
CGroup: /system.slice/roomba.service
└─3233 /usr/bin/python3 /home/pi/domoticz/plugins/Roomba/mqtt_Roomba.py

So de service is running. But there is no change in Domoticz. But when I run "sudo service roomba stop" and then "Sudo service roomba start" or I run "Sudo service roomba restart" the status in Domoticz is updated after a couple of seconds.

In a couple of post earlier you gave me a command to run to test the response of the Roomba. "mosquitto_sub -v -t /roomba/feedback/#" When my Roomba is running it gives a response. That stops when he is on his dock and charging.

Can I do anything to keep the roomba service sort of alive?

Thank you again for your help.
If you look to one of the "issues" on the GitHub, you will see that somebody reported that update stopped after there was a connection interrupt (probably between ROOMBA and router). He detected this because he had a daily reboot and afterwards it did not work.
So I would suggest you two things:
* check if there are network interrupts
* I propose you stop the service and start the python script manually (with debug information). It is indicated in the procedure on GitHub how to do. Of course you will need to keep your SSH session open...

"That stops when he is on his dock and charging." I don't know exactly anymore the behavior at my side. Will check once this weekend... Now. If mosquitto_sub does not receive updates, it is normal that the python script/service does not get it either. This makes me thinking about another possible topic... You should also check the status of the mosquitto service... As there is a dependency of the roobma service with mosquitto, it is possible after a restart of the roomba service, the mosquitto is restarted again... And perhaps the problem is at the mosquitto service. Thanks to supply your findings about this topic.

From my side (but this weekend probably) I will see to make the script more robust in case of network interrupt... However strange enough, I never detected such problem at my side... All is running since some months without any problem. I regularly check (since your message) if the updates are still in Domoticz and it is... However I know that I already had network interrupts...
Svennie
Posts: 13
Joined: Sunday 25 October 2020 14:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Helmond
Contact:

Re: iRobot Roomba 980 integration

Post by Svennie »

Filip wrote: Thursday 28 January 2021 21:46
Svennie wrote: Wednesday 27 January 2021 21:34 Filip,

I encountered an issue. The Plugin works great. But... after 10, 30, 60 or 2 hours the plugin isn't updating the status of my Roomba S9.
Even do my Roomba is running.

When u run the command: sudo service roomba status, I get the following.

pi@raspberrypi:~ $ sudo service roomba status
● roomba.service - Roomba mqtt client
Loaded: loaded (/etc/systemd/system/roomba.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2021-01-27 18:11:53 CET; 31min ago
Main PID: 3233 (python3)
Tasks: 1 (limit: 2182)
CGroup: /system.slice/roomba.service
└─3233 /usr/bin/python3 /home/pi/domoticz/plugins/Roomba/mqtt_Roomba.py

So de service is running. But there is no change in Domoticz. But when I run "sudo service roomba stop" and then "Sudo service roomba start" or I run "Sudo service roomba restart" the status in Domoticz is updated after a couple of seconds.

In a couple of post earlier you gave me a command to run to test the response of the Roomba. "mosquitto_sub -v -t /roomba/feedback/#" When my Roomba is running it gives a response. That stops when he is on his dock and charging.

Can I do anything to keep the roomba service sort of alive?

Thank you again for your help.
If you look to one of the "issues" on the GitHub, you will see that somebody reported that update stopped after there was a connection interrupt (probably between ROOMBA and router). He detected this because he had a daily reboot and afterwards it did not work.
So I would suggest you two things:
* check if there are network interrupts
* I propose you stop the service and start the python script manually (with debug information). It is indicated in the procedure on GitHub how to do. Of course you will need to keep your SSH session open...

"That stops when he is on his dock and charging." I don't know exactly anymore the behavior at my side. Will check once this weekend... Now. If mosquitto_sub does not receive updates, it is normal that the python script/service does not get it either. This makes me thinking about another possible topic... You should also check the status of the mosquitto service... As there is a dependency of the roobma service with mosquitto, it is possible after a restart of the roomba service, the mosquitto is restarted again... And perhaps the problem is at the mosquitto service. Thanks to supply your findings about this topic.

From my side (but this weekend probably) I will see to make the script more robust in case of network interrupt... However strange enough, I never detected such problem at my side... All is running since some months without any problem. I regularly check (since your message) if the updates are still in Domoticz and it is... However I know that I already had network interrupts...
Filip,

Today I have taken a closer look a the Domoticz log. This morning de service wasn't working correctly. So I stopped it. And start 'python3 mqtt_Roomba.py' And to test it's performance I manually started a job for the Roomba. The change in status came thru in Domoticz. So far so good. Then I stopped the job. That's where it all went wrong. See below for the output:

pi@raspberrypi:~/domoticz/plugins/Roomba $ python3 mqtt_Roomba.py
CV or numpy module not found, falling back to PIL
PIL module not found, maps are disabled
<CTRL C> to exit
Subscribe to /roomba/feedback/# to see published data
Broker Connected with result code 0
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 3452, in _thread_main
self.loop_forever(retry_first_connection=True)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1779, in loop_forever
rc = self.loop(timeout, max_packets)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1181, in loop
rc = self.loop_read(max_packets)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1572, in loop_read
rc = self._packet_read()
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 2310, in _packet_read
rc = self._packet_handle()
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 2936, in _packet_handle
return self._handle_publish()
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 3216, in _handle_publish
self._handle_on_message(message)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 3444, in _handle_on_message
self.on_message(self, self._userdata, message)
File "/home/pi/domoticz/plugins/Roomba/roomba/roomba.py", line 459, in on_message
self.decode_topics(json_data)
File "/home/pi/domoticz/plugins/Roomba/roomba/roomba.py", line 713, in decode_topics
self.update_state_machine()
File "/home/pi/domoticz/plugins/Roomba/roomba/roomba.py", line 820, in update_state_machine
self.current_state = self.states[self.cleanMissionStatus_phase]
KeyError: 'evac'

After that there where no changes in Domoticz anymore. So I Rebooted my Pi and checked to see if the Roomba service was running and it was. After that I kept my my I eye on the Domoticz log after I switch to the debug mode for the plugin in Domoticz. In a constant pace de updates kept coming in. After a couple of hours I started a job and let it finished it. That to went well. Did another job shortly after that en that went oke to.

So I believe that stopping a job and canceling it, so that the Roomba go's back to the dock, is the problem somehow.

Hopefully you can do something with my comments.

greetz Sven
Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by Filip »

Svennie wrote: Friday 29 January 2021 21:39
Filip wrote: Thursday 28 January 2021 21:46
Svennie wrote: Wednesday 27 January 2021 21:34 Filip,

I encountered an issue. The Plugin works great. But... after 10, 30, 60 or 2 hours the plugin isn't updating the status of my Roomba S9.
Even do my Roomba is running.

When u run the command: sudo service roomba status, I get the following.

pi@raspberrypi:~ $ sudo service roomba status
● roomba.service - Roomba mqtt client
Loaded: loaded (/etc/systemd/system/roomba.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2021-01-27 18:11:53 CET; 31min ago
Main PID: 3233 (python3)
Tasks: 1 (limit: 2182)
CGroup: /system.slice/roomba.service
└─3233 /usr/bin/python3 /home/pi/domoticz/plugins/Roomba/mqtt_Roomba.py

So de service is running. But there is no change in Domoticz. But when I run "sudo service roomba stop" and then "Sudo service roomba start" or I run "Sudo service roomba restart" the status in Domoticz is updated after a couple of seconds.

In a couple of post earlier you gave me a command to run to test the response of the Roomba. "mosquitto_sub -v -t /roomba/feedback/#" When my Roomba is running it gives a response. That stops when he is on his dock and charging.

Can I do anything to keep the roomba service sort of alive?

Thank you again for your help.
If you look to one of the "issues" on the GitHub, you will see that somebody reported that update stopped after there was a connection interrupt (probably between ROOMBA and router). He detected this because he had a daily reboot and afterwards it did not work.
So I would suggest you two things:
* check if there are network interrupts
* I propose you stop the service and start the python script manually (with debug information). It is indicated in the procedure on GitHub how to do. Of course you will need to keep your SSH session open...

"That stops when he is on his dock and charging." I don't know exactly anymore the behavior at my side. Will check once this weekend... Now. If mosquitto_sub does not receive updates, it is normal that the python script/service does not get it either. This makes me thinking about another possible topic... You should also check the status of the mosquitto service... As there is a dependency of the roobma service with mosquitto, it is possible after a restart of the roomba service, the mosquitto is restarted again... And perhaps the problem is at the mosquitto service. Thanks to supply your findings about this topic.

From my side (but this weekend probably) I will see to make the script more robust in case of network interrupt... However strange enough, I never detected such problem at my side... All is running since some months without any problem. I regularly check (since your message) if the updates are still in Domoticz and it is... However I know that I already had network interrupts...
Filip,

Today I have taken a closer look a the Domoticz log. This morning de service wasn't working correctly. So I stopped it. And start 'python3 mqtt_Roomba.py' And to test it's performance I manually started a job for the Roomba. The change in status came thru in Domoticz. So far so good. Then I stopped the job. That's where it all went wrong. See below for the output:

pi@raspberrypi:~/domoticz/plugins/Roomba $ python3 mqtt_Roomba.py
CV or numpy module not found, falling back to PIL
PIL module not found, maps are disabled
<CTRL C> to exit
Subscribe to /roomba/feedback/# to see published data
Broker Connected with result code 0
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 3452, in _thread_main
self.loop_forever(retry_first_connection=True)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1779, in loop_forever
rc = self.loop(timeout, max_packets)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1181, in loop
rc = self.loop_read(max_packets)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1572, in loop_read
rc = self._packet_read()
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 2310, in _packet_read
rc = self._packet_handle()
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 2936, in _packet_handle
return self._handle_publish()
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 3216, in _handle_publish
self._handle_on_message(message)
File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 3444, in _handle_on_message
self.on_message(self, self._userdata, message)
File "/home/pi/domoticz/plugins/Roomba/roomba/roomba.py", line 459, in on_message
self.decode_topics(json_data)
File "/home/pi/domoticz/plugins/Roomba/roomba/roomba.py", line 713, in decode_topics
self.update_state_machine()
File "/home/pi/domoticz/plugins/Roomba/roomba/roomba.py", line 820, in update_state_machine
self.current_state = self.states[self.cleanMissionStatus_phase]
KeyError: 'evac'

After that there where no changes in Domoticz anymore. So I Rebooted my Pi and checked to see if the Roomba service was running and it was. After that I kept my my I eye on the Domoticz log after I switch to the debug mode for the plugin in Domoticz. In a constant pace de updates kept coming in. After a couple of hours I started a job and let it finished it. That to went well. Did another job shortly after that en that went oke to.

So I believe that stopping a job and canceling it, so that the Roomba go's back to the dock, is the problem somehow.

Hopefully you can do something with my comments.

greetz Sven
Hey Sven,
This is normal... When interrupting/quitting by CTR-C you get indeed a stack trace and this depends what the program was busy at that moment...
So this is not any problem. And it is also normal that when this program is stopped, Domoticz doesn't receive anything.
What you should do is starting indeed the program manual by using "python3 mqtt_Roomba.py -D 3" (the -D 3 gives debug output). Don't forget to stop the service "sudo service roomba stop" before.
And if something goes wrong, the output is what I need. And also check then the status of mosquitto with "sudo service mosquitto status".
You don't need to restart the whole RPI afterwards. You can simply restart the service by "sudo service roomba start".
Svennie
Posts: 13
Joined: Sunday 25 October 2020 14:57
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Helmond
Contact:

Re: iRobot Roomba 980 integration

Post by Svennie »

Hi Filip.

I got the time today to install your plugin on my other Pi. I saw that you change the install. I have the old version of your plugin semi working on my Rpi 3. It works with mij Roomba S9 after hij restart the Roomba Service. Now I try to install it on my Rpi 4. When I try to check if there is a connection between my S9 en the Pi with the command: python3 roomba --topic /roomba/feedback/# --broker localhost --brokerFeedback /roomba/feedback --mapPath '' --mapSize '' --log '' from the folder /home/pi/domoticz/plugins/Roomba I get the next output.

pi@raspberrypi:~/domoticz/plugins/Roomba $ python3 roomba --topic /roomba/feedback/# --broker localhost --brokerFeedback /roomba/feedback --mapPath '' --mapSize '' --log ''
CV or numpy module not found, falling back to PIL
CV or numpy module not found, falling back to PIL
[I 2021-02-13 21:42:38,493] *******************
[I 2021-02-13 21:42:38,493] * Program Started *
[I 2021-02-13 21:42:38,494] *******************
[I 2021-02-13 21:42:38,494] Roomba.py Version: 1.2.9
[I 2021-02-13 21:42:38,494] Python Version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
[I 2021-02-13 21:42:38,494] Paho MQTT Version: 1.5.1
[I 2021-02-13 21:42:38,494] PIL Version: 5.4.1
[I 2021-02-13 21:42:38,494] <CNTRL C> to Exit
[I 2021-02-13 21:42:38,494] Roomba 980 MQTT data Interface
[I 2021-02-13 21:42:38,496] reading info from config file ./config.ini
[I 2021-02-13 21:42:38,497] connecting to broker
[I 2021-02-13 21:42:38,503] Creating Roomba object 192.168.1.62
[I 2021-02-13 21:42:38,503] connecting Roomba 192.168.1.62

This is the output I get. Until I push CNTRL C en then it stops. I believe it cannot connect to my Roomba.
When I run the commend: 'python3 roomba --topic /roomba/feedback/# --broker localhost --brokerFeedback /roomba/feedback --mapPath '' --mapSize '' --log '' --debug' This is the output.

CV or numpy module not found, falling back to PIL
CV or numpy module not found, falling back to PIL
[I 2021-02-13 21:54:50,548] *******************
[I 2021-02-13 21:54:50,548] * Program Started *
[I 2021-02-13 21:54:50,549] *******************
[I 2021-02-13 21:54:50,549] Roomba.py Version: 1.2.9
[I 2021-02-13 21:54:50,549] Python Version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
[I 2021-02-13 21:54:50,549] Paho MQTT Version: 1.5.1
[I 2021-02-13 21:54:50,549] PIL Version: 5.4.1
[D 2021-02-13 21:54:50,549] -- DEBUG Mode ON -
[I 2021-02-13 21:54:50,549] <CNTRL C> to Exit
[I 2021-02-13 21:54:50,549] Roomba 980 MQTT data Interface
[I 2021-02-13 21:54:50,551] reading info from config file ./config.ini
[I 2021-02-13 21:54:50,553] connecting to broker
[I 2021-02-13 21:54:50,558] Creating Roomba object 192.168.1.62
[I 2021-02-13 21:54:50,559] connecting Roomba 192.168.1.62
Error: [Errno 111] Connection refused
Attempting new Connection to Roomba (#1)
Error: [Errno 111] Connection refused
Attempting new Connection to Roomba (#2)
Error: [Errno 111] Connection refused
Attempting new Connection to Roomba (#3)
Error: [Errno 111] Connection refused
Unable to connect to Roomba Lydia
[D 2021-02-13 21:54:53,959] Broker disconnected
What can I do to fix this?
Filip
Posts: 100
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by Filip »

Svennie wrote: Saturday 13 February 2021 21:52 Hi Filip.

I got the time today to install your plugin on my other Pi. I saw that you change the install. I have the old version of your plugin semi working on my Rpi 3. It works with mij Roomba S9 after hij restart the Roomba Service. Now I try to install it on my Rpi 4. When I try to check if there is a connection between my S9 en the Pi with the command: python3 roomba --topic /roomba/feedback/# --broker localhost --brokerFeedback /roomba/feedback --mapPath '' --mapSize '' --log '' from the folder /home/pi/domoticz/plugins/Roomba I get the next output.

pi@raspberrypi:~/domoticz/plugins/Roomba $ python3 roomba --topic /roomba/feedback/# --broker localhost --brokerFeedback /roomba/feedback --mapPath '' --mapSize '' --log ''
CV or numpy module not found, falling back to PIL
CV or numpy module not found, falling back to PIL
[I 2021-02-13 21:42:38,493] *******************
[I 2021-02-13 21:42:38,493] * Program Started *
[I 2021-02-13 21:42:38,494] *******************
[I 2021-02-13 21:42:38,494] Roomba.py Version: 1.2.9
[I 2021-02-13 21:42:38,494] Python Version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
[I 2021-02-13 21:42:38,494] Paho MQTT Version: 1.5.1
[I 2021-02-13 21:42:38,494] PIL Version: 5.4.1
[I 2021-02-13 21:42:38,494] <CNTRL C> to Exit
[I 2021-02-13 21:42:38,494] Roomba 980 MQTT data Interface
[I 2021-02-13 21:42:38,496] reading info from config file ./config.ini
[I 2021-02-13 21:42:38,497] connecting to broker
[I 2021-02-13 21:42:38,503] Creating Roomba object 192.168.1.62
[I 2021-02-13 21:42:38,503] connecting Roomba 192.168.1.62

This is the output I get. Until I push CNTRL C en then it stops. I believe it cannot connect to my Roomba.
When I run the commend: 'python3 roomba --topic /roomba/feedback/# --broker localhost --brokerFeedback /roomba/feedback --mapPath '' --mapSize '' --log '' --debug' This is the output.

CV or numpy module not found, falling back to PIL
CV or numpy module not found, falling back to PIL
[I 2021-02-13 21:54:50,548] *******************
[I 2021-02-13 21:54:50,548] * Program Started *
[I 2021-02-13 21:54:50,549] *******************
[I 2021-02-13 21:54:50,549] Roomba.py Version: 1.2.9
[I 2021-02-13 21:54:50,549] Python Version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
[I 2021-02-13 21:54:50,549] Paho MQTT Version: 1.5.1
[I 2021-02-13 21:54:50,549] PIL Version: 5.4.1
[D 2021-02-13 21:54:50,549] -- DEBUG Mode ON -
[I 2021-02-13 21:54:50,549] <CNTRL C> to Exit
[I 2021-02-13 21:54:50,549] Roomba 980 MQTT data Interface
[I 2021-02-13 21:54:50,551] reading info from config file ./config.ini
[I 2021-02-13 21:54:50,553] connecting to broker
[I 2021-02-13 21:54:50,558] Creating Roomba object 192.168.1.62
[I 2021-02-13 21:54:50,559] connecting Roomba 192.168.1.62
Error: [Errno 111] Connection refused
Attempting new Connection to Roomba (#1)
Error: [Errno 111] Connection refused
Attempting new Connection to Roomba (#2)
Error: [Errno 111] Connection refused
Attempting new Connection to Roomba (#3)
Error: [Errno 111] Connection refused
Unable to connect to Roomba Lydia
[D 2021-02-13 21:54:53,959] Broker disconnected
What can I do to fix this?
Hi Sven,
I really don't understand what is happening at your side. It is working as a charm with Roomba i9. The only topic that I need to followup is that the service exceptionally stops (I had it after an automatic OS updated and before reboot) to find the solution.
I start thinking that you are having an S9 and that this one is not compatible with the i9 (should work also with the 980).
So perhaps to wait a bit until others have the same problem (and perhaps solution).
Kr (and really sorry).
Filip
astrapowerrr
Posts: 141
Joined: Tuesday 31 January 2017 20:34
Target OS: -
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by astrapowerrr »

hi all im trying to install this plugin but cant get my broker to work.
something goes wrong with the conf file.

can someone help me out with this.. absolute non linux knowledge.

i now have the following text in the conf file:
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.gz

pid_file /run/mosquitto/mosquitto.pid

persistence false
persistence_location /var/lib/mosquitto/

log_dest none

include_dir /etc/mosquitto/conf.d
i have edit the conf file in the /etc/mosquitto folder and i believe it has to be copied into the conf.d folder?
when i do this nothing helps.. only errors..
oh so i lost the original conf file too because i edited it....

my problem is that my broker just doesnt work when using

Code: Select all

mosquitto_sub -v -t /roomba/feedback/#
it gives me

Code: Select all

-bash: mosquitto_sub: opdracht niet gevonden


need some help here because i just dont know what i am doing and making more problems than fixing it when google it..

greets marco
ResetElonex
Posts: 3
Joined: Tuesday 17 June 2014 13:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: iRobot Roomba 980 integration

Post by ResetElonex »

Hi,
I got started on the great script bewo posted. But I didn't like all of the German ;) . So I have translated it to English, and made some corrections.
Just sharing back.
Spoiler: show
--[[
Script to get data from Roomba devices, using Rest980 by Koalazak.
Original script by bewo found on viewtopic.php?p=232887#p232887
This is mainly a translation from German, and some corrections.

Instructions:
-------------------------
-> For every Roomba, set the iRobotname and the Rest-API-URL!
Following items have to be created per Roomba:
- Selector switch with following fields (in that order): Charging, Dock, Error, Pause, Cleaning
- Sensor-Device for BatteryStatus (Custom Sensor). Name: "*iRobotname* BatteryStatus"
- Text-Device for Wastebin-Status. Name: "*iRobotname* Status Wastebin"
- Custom counter device (unit "Min"). Name: "*iRobotname* Cleaning Duration"

Following user variables have to be created:
- *iRobotname*_JSON_Mission_Type (string)
- *iRobotname*_JSON_Status (string)
- *iRobotname*_Warningstate (string)
- *iRobotname*_Duration (integer)

Please replace "*iRobotname*" by the actual name of the device!
For example, if the Roomba is called Cinderella, the first variable's name is "Cinderella_JSON_Mission_Type"

--]]

json = (loadfile "/opt/domoticz/scripts/lua/JSON.lua")()

commandArray = {}

-- Enter one line per roomba (create a rest980 instance per roomba, on separate ports):
iRobot = {

Downstairs = { Name = 'Cinderella', API_URL = 'http://ubuntu:3000/api/local' },
}


-- Start:
for iRobot,iRobot in pairs(iRobot) do

-- Since the roomba is connected to wifi, check wifi first. I have a "System Alive Checker (Ping)" set up for this.
if otherdevices['synologyrouter'] == 'On' then

-- #############################################################################################################

-- Write info from roomba in a LUA table
json_call=assert(io.popen('curl '..iRobot.API_URL..'/info/mission'))
json_iRobot_Data = json_call:read('*all')
json_call:close()
iRobot_Data = json:decode(json_iRobot_Data)

-- Info details:
Mission_Type = iRobot_Data.cleanMissionStatus.cycle -- Mission type
Status = iRobot_Data.cleanMissionStatus.phase -- Current Status
--Mission_Finish = iRobot_Data.cleanMissionStatus.expireM -- Time until finished
--Battery_Remain = iRobot_Data.cleanMissionStatus.rechrgM -- Time until empty battery
ErrorState = iRobot_Data.cleanMissionStatus.error -- Error happening, gives a number
Not_Ready = iRobot_Data.cleanMissionStatus.notReady -- Status "Not Ready", gives a number
--Mission_Time = iRobot_Data.cleanMissionStatus.mssnM -- Mission time
--Mission_Area = iRobot_Data.cleanMissionStatus.sqft -- Cleaned area in this mission
--Mission_Initiator = iRobot_Data.cleanMissionStatus.initiator -- Mission initiator
--Mission_Nummer = iRobot_Data.cleanMissionStatus.nMssn -- Mission number
Wastebin_Present = tostring(iRobot_Data.bin.present) -- Wastebin installed Yes/No
Wastebin_Full = tostring(iRobot_Data.bin.full) -- Wastebin full Yes/No
Battery_Percentage = iRobot_Data.batPct -- Current battery in percent


-- #############################################################################################################

-- Update Domoticz User Variables if needed (see below for the creations needed):

-- Write mission type in user variable:
if Mission_Type ~= uservariables[iRobot.Name..'_JSON_Mission_Type'] then
commandArray[#commandArray+1] = {['Variable:'..iRobot.Name..'_JSON_Mission_Type'] = Mission_Type}
print('Roomba: '..iRobot.Name..' -> Mission type set to '..Mission_Type)
end

-- Write status to user variable:
if Status ~= uservariables[iRobot.Name..'_JSON_Status'] then
commandArray[#commandArray+1] = {['Variable:'..iRobot.Name..'_JSON_Status'] = Status}
print('Roomba: '..iRobot.Name..' -> Status set to '..Status)
end

-- #############################################################################################################

-- Set errors and notifications:

if ErrorState > 0 or (Not_Ready > 0 and Not_Ready < 15) and otherdevices[iRobot.Name] ~= 'Error' and
Wastebin_Present == 'true' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 20'} -- Level 20 = Error
print('Roomba: '..iRobot.Name..' -> Warning! ErrorState number.: '..ErrorState..' has been reported.')
if uservariables[iRobot.Name..'_Warningstate'] ~= 'Sent: Error' then
commandArray[#commandArray+1] = {['SendNotification'] = string.upper(iRobot.Name)..'#Warning: '..iRobot.Name..' reports an Error. Please check!'}
commandArray[#commandArray+1] = {['Variable:'..iRobot.Name..'_Warningstate'] = 'Sent: Error'} -- Level 20 = Error
end

elseif Not_Ready == 15 then
if Battery_Percentage <= 20 and otherdevices[iRobot.Name] ~= 'Error' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 20'} -- Level 20 = Error
print('Roomba: '..iRobot.Name..' -> Warning battery empty!')
if string.sub(uservariables[iRobot.Name..'_Warningstate'], 1, 4) ~= 'Sent' then
commandArray[#commandArray+1] = {['SendNotification'] = string.upper(iRobot.Name)..'#Warning, '..iRobot.Name..' battery is empty, please return to dock manually!'}
commandArray[#commandArray+1] = {['Variable:'..iRobot.Name..'_Warningstate'] = 'Sent: Battery empty'}
end
elseif Battery_Percentage > 20 and otherdevices[iRobot.Name] ~= 'Charging' and Mission_Type == 'none' and Status == 'charge' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 0'} -- Level 0 = Charging
print('Roomba: '..iRobot.Name..' -> Battery was empty, charging!')
if string.sub(uservariables[iRobot.Name..'_Warningstate'], 1, 4) ~= 'Sent' then
commandArray[#commandArray+1] = {['Variable:'..iRobot.Name..'_Warningstate'] = 'Ready'}
end
end
end

-- Release Error:
if ErrorState == 0 and Not_Ready == 0 then
if uservariables[iRobot.Name..'_Warningstate'] == 'Sent: Error' then
commandArray[#commandArray+1] = {['Variable:'..iRobot.Name..'_Warningstate'] = 'Ready'}
print('Roomba: '..iRobot.Name..' -> Warningstate has been reset to Ready.')
end
end


-- #############################################################################################################

-- Wastebin-Service (Show warning and symbol)

Wastebin_device = iRobot.Name..' Status Wastebin'

-- Set Status to OK and reset Duration
if Wastebin_Present == 'true' then

if uservariables[iRobot.Name..'_Duration'] <= 45 then
textstatus = 'Wastebin empty, everything OK!'
if otherdevices_svalues[Wastebin_device] ~= textstatus then
commandArray[#commandArray+1] = {['UpdateDevice'] = otherdevices_idx[Wastebin_device]..'|1|'..textstatus} -- 1 = green
print('Roomba: '..iRobot.Name..' -> Status Wastebin updated.')
end
-- Reset Warningstate
if uservariables[iRobot.Name..'_Warningstate'] == 'Sent: Empty wastebin' then
commandArray[#commandArray+1] = {['Variable:'..iRobot.Name..'_Warningstate'] = 'Ready'}
end

-- Update wastebin status when roomba has run for a while.
elseif uservariables[iRobot.Name..'_Duration'] > 45 and uservariables[iRobot.Name..'_Duration'] < 90 then
textstatus = 'Wastebin has some waste.'
if otherdevices_svalues[Wastebin_device] ~= textstatus then
commandArray[#commandArray+1] = {['UpdateDevice'] = otherdevices_idx[Wastebin_device]..'|2|'..textstatus} -- 2 = yellow
print('Roomba: '..iRobot.Name..' -> Status Wastebin updated.')
end

-- Notify when bin is suspected to be full.
elseif uservariables[iRobot.Name..'_Duration'] >= 90 then
textstatus = 'Wastebin is probably full. Please empty!'
if otherdevices_svalues[Wastebin_device] ~= textstatus then
commandArray[#commandArray+1] = {['UpdateDevice'] = otherdevices_idx[Wastebin_device]..'|3|'..textstatus} -- 3 = orange
print('Roomba: '..iRobot.Name..' -> Status Wastebin updated.')
end
if string.sub(uservariables[iRobot.Name..'_Warningstate'], 1, 4) ~= 'Sent' then
commandArray[#commandArray+1] = {['SendNotification'] = string.upper(iRobot.Name)..'#The wastebin of '..iRobot.Name..' is probably full. Please empty!'}
commandArray[#commandArray+1] = {['Variable:'..iRobot.Name..'_Warningstate'] = 'Sent: Empty wastebin' }
end
end

else
-- Wastebin was taken out. Reset status wastebin and duration:
textstatus = 'Wastebin is removed'
if otherdevices[Wastebin_device] ~= textstatus then
commandArray[#commandArray+1] = {['UpdateDevice'] = otherdevices_idx[Wastebin_device]..'|0|'..textstatus} -- 0 = grey
commandArray[#commandArray+1] = {['Variable:'..iRobot.Name..'_Duration'] = tostring(0) }
print('Roomba: '..iRobot.Name..' -> Status Wastebin updated.')
end
end


-- The roomba has reported a full bin. Send notification:
if Wastebin_Full == 'true' and otherdevices[iRobot.Name] ~= 'Error' then
textstatus = 'Wastebin is full. Please empty urgently!'
if otherdevices_svalues[Wastebin_device] ~= textstatus then
commandArray[#commandArray+1] = {['UpdateDevice'] = otherdevices_idx[Wastebin_device]..'|4|'..textstatus} -- 3 = red
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 20' } -- Level 20 = Error
print('Roomba: '..iRobot.Name..' -> Status Wastebin updated.')
end
if string.sub(uservariables[iRobot.Name..'_Warningstate'], 1, 4) ~= 'Sent' then
print(iRobot.Name..': Warning, wastebin is full. Please empty urgently!')
commandArray[#commandArray+1] = {['SendNotification'] = string.upper(iRobot.Name)..'#Warning, wastebin of '..iRobot.Name..' is full. Please empty urgently!'}
commandArray[#commandArray+1] = {['Variable:'..iRobot.Name..'_Warningstate'] = 'Sent: Empty wastebin' }
end
end

-- #############################################################################################################

-- Update battery status:

battery_device = iRobot.Name..' BatteryStatus'

-- Determine battery symbol:
if Battery_Percentage <= 20 then
batterysymbol = '102'
elseif Battery_Percentage > 20 and Battery_Percentage <= 50 then
batterysymbol = '104'
elseif Battery_Percentage > 50 and Battery_Percentage <= 90 then
batterysymbol = '101'
elseif Battery_Percentage > 90 then
batterysymbol = '103'
end

-- Write BatteryStatus
if Battery_Percentage ~= tonumber(otherdevices_svalues[battery_device]) then
commandArray[#commandArray+1] = {['UpdateDevice'] = otherdevices_idx[battery_device]..'|0|'..Battery_Percentage}
print('Roomba: '..iRobot.Name..' -> BatteryStatus updated to '..Battery_Percentage..'%.')
-- os.execute('curl "http://localhost:8080/json.htm?type=set ... &used=true"')
end


-- Set Dock mode when battery runs low:
if Battery_Percentage <= 30 and Status ~= 'hmUsrDock' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 10' } -- Level 10 = Dock
print('Roomba: '..iRobot.Name..' -> Battery is running low. Dock mode set.')
end

-- #############################################################################################################

-- Update Roomba status, when manually operated:

if ErrorState == 0 and Not_Ready == 0 then

-- Roomba is heading for the Dock:
if (Mission_Type == 'clean' or Mission_Type == 'dock') and Status == 'hmUsrDock' and
otherdevices[iRobot.Name] ~= 'Dock' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 10' } -- Level 10 = Dock
print('Roomba: '..iRobot.Name..' -> Status updated to Dock')

-- Roomba is on the Dock, but the battery is not full:
elseif Mission_Type == 'none' and Status == 'charge' and Battery_Percentage <= 80 and
otherdevices[iRobot.Name] ~= 'Charging' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 0' } -- Level 0 = Charging
print('Roomba: '..iRobot.Name..' -> Status updated to Charging')

-- Roomba is on the Dock, and the battery is full enough:
elseif Mission_Type == 'none' and Status == 'charge' and Battery_Percentage > 80 and
otherdevices[iRobot.Name] ~= 'Dock' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 10' } -- Level 10 = Dock
print('Roomba: '..iRobot.Name..' -> Status updated to Dock')

-- Roomba is not on the Dock, and is not cleaning. Likely paused:
elseif (Mission_Type == 'none' or Mission_Type == 'clean') and Status == 'stop' and
otherdevices[iRobot.Name] ~= 'Pause' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 30' } -- Level 30 = Pause
print('Roomba: '..iRobot.Name..' -> Status updated to Pause')

-- Roomba is spotcleaning:
elseif Mission_Type == 'spot' and Status == 'run' and
otherdevices[iRobot.Name] ~= 'Cleaning' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 40' } -- Level 40 = Cleaning
print('Roomba: '..iRobot.Name..' -> Status updated to Cleaning')

-- Roomba is in normal usage mode:
elseif Mission_Type == 'clean' and (Status == 'run' or Status == 'hmPostMsn') and
otherdevices[iRobot.Name] ~= 'Cleaning' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 40' } -- Level 40 = Cleaning
print('Roomba: '..iRobot.Name..' -> Status updated to Cleaning')
-- Roomba is in quick clean mode:
elseif Mission_Type == 'quick' and (Status == 'run' or Status == 'hmPostMsn') and
otherdevices[iRobot.Name] ~= 'Cleaning' then
commandArray[#commandArray+1] = {[iRobot.Name] = 'Set Level 40' } -- Level 40 = Cleaning
print('Roomba: '..iRobot.Name..' -> Status updated to Cleaning')
end

end
end


-- Keep BatteryStatus active (no WLAN, or when no change is reported)
if os.date('*t').min == 15 then
Battery_Percentage = tonumber(otherdevices_svalues[iRobot.Name..' BatteryStatus'])
commandArray[#commandArray+1]={['UpdateDevice'] = otherdevices_idx[iRobot.Name..' BatteryStatus']..'|0|'..Battery_Percentage}
print('Roomba: '..iRobot.Name..' -> BatteryStatus kept active.')
end
-- Count the working time
if otherdevices[iRobot.Name] == 'Cleaning' then
working_time_variable = tonumber(uservariables[iRobot.Name..'_Duration']) + 1
working_time_counter = tonumber(otherdevices_svalues[iRobot.Name..' Cleaning Duration']) + 1
commandArray[#commandArray+1]={['Variable:'..iRobot.Name..'_Duration'] = tostring(working_time_variable)}
commandArray[#commandArray+1]={['UpdateDevice'] = otherdevices_idx[iRobot.Name..' Cleaning Duration']..'|1|'..tonumber(working_time_counter)}
end
end



return commandArray
For the screenshots (even though they are still in German), please refer to viewtopic.php?p=232887#p232887
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests