Giter Site home page Giter Site logo

Comments (4)

gregorij89 avatar gregorij89 commented on August 14, 2024

Ok, so some update. I was able to successfully connect to Roomba MQTT broker. The settings in my first post are correct, but it is important to configure OpenHab to accept TLS connection to Roomba MQTT with their own certificate. So steps:

  1. It is needed to get the Roomba CA certificate. I´ve done that via openssl from MQTT broker of my Roomba. I think that all Roombas will have the same CA, so I am posting this certificate as an attachment to my post. But I am strongly recommending to everyone interested, to check the CA certificate of their own Roomba. Attached certificate is in the PEM format. RoombaCA.txt

  2. Then you need to set up a trust in this certificate from OpenHab. This process is described in the OpenHab forum in the MQTT Binding and SSL article. Basically, my set of commands:
    cd /etc/openhab2
    sudo keytool -genkeypair -alias myopenhab -keyalg RSA -keystore keystore.jks
    sudo keytool -importcert -alias RoombaCA -trustcacerts -file /tmp/RoombaCA.crt -storetype JKS -keystore truststore.jks
    Then you need to modify /usr/share/openhab2/runtime/bin/setenv according to the article. After rebooting OpenHab, the connection to the MQTT broker is sucessfully created.

  3. Then you need to alter every occurance of autoupdate=false to autoupdate="false" in roomba.items file.

  4. Now, OpenHab says no error and loads items file and site map.

Here is when the things end. I can open the Roomba group in OpenHab basic UI but no value is loaded from my Roomba. When I try to send a command to my Roomba, nothing happen and in the OpenHab log files, I can see:

==> /var/log/openhab2/events.log <==
2018-11-13 10:53:56.085 [ome.event.ItemCommandEvent] - Item 'roomba_command' received command start

==> /var/log/openhab2/openhab.log <==
2018-11-13 10:53:56.243 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
org.eclipse.paho.client.mqttv3.MqttException: Connection lost
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146) [210:org.openhab.io.transport.mqtt:1.12.0]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107) ~[?:?]
... 1 more
2018-11-13 10:53:56.245 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'proliant' was lost: Connection lost : ReasonCode 32109 : Cause : null
2018-11-13 10:53:56.245 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'proliant'
2018-11-13 10:54:06.246 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'proliant'
2018-11-13 10:54:36.570 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting undefined value [sourcePattern=%, targetPattern=%, exceptionMessage=Conversion = '%']
2018-11-13 10:54:48.578 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting undefined value [sourcePattern=%, targetPattern=%, exceptionMessage=Conversion = '%']

So I am one step closer, but still far away from desired status. Anybody dealing with the same issues?

Thanks

George

from roomba980-python.

NickWaterton avatar NickWaterton commented on August 14, 2024

George,

You seem to be doing things very differently to what I intended when I created the Roomba interface for OH2. This is supposed to be a very simple configuration, which you are fundamentally misunderstanding.

The roomba.py program is intended to be a bridge from the Roomba mqtt server to your own mqtt server. The Roomba mqtt server only allows one connection, so my program connects to the Roomba mqtt server (and takes care of the login, password, TLS encryption, certificates etc), then bidirectionally forwards the Roomba mqtt messages to your own mqtt server, decoding/encoding the json in the process. You then use the OH2 mqtt binding to bind items to your own mqtt server topics decoded from the Roomba messages.

each json item is decoded and published as a separate topic. To see the topic published and their values run: mosquitto_sub -v -t /roomba/feedback/#

So the first step is to set up your own mqtt server. What platform are you running OH2 on?

The problem starts with the mqtt.cfg settings. On my system, this is configuring my mqtt server, nothing to do with the Roomba at all. proliant is my server name (which is what OH2 is running on).

You seem to be trying to set OH2's mqtt server source to be the Roomba itself - which will not work, as the roomba is sending/receiving json, not text.

So, How to control Roomba from OH2:

  1. Set up your own mqtt server (Ubuntu/raspian/debian sudo apt-get install mosquitto mosquitto-clients)
  2. install the OH2 mqtt binding
  3. Configure OH2 mqtt.cfg with your own mqtt server settings.
    example:
myservername.url=tcp://localhost:1883 // or my mqtt server IP if it's not the localhost
myservername.clientId=Openhab2Connection //any unique label to identify the connection
//myservername.user=user //optional, not created by default
//myservername.pwd=passwd //optional, not created by default

leave out user name and password if you have not created an mqtt user or password for your mqtt server, these are not created by default.

  1. Run roomba.py (include options for your own mqtt server if needed, ip, port, user, password - the defaults work for simple installs, so you can leave them out) - messages should now be passed back and forth between the roomba, and your own mqtt server (you can see them in the log), and you can check what your mqtt server is receiving using mosquitto_sub -v -t /roomba/feedback/# (with -h ip if the server is not on your localhost).

  2. Configure OH2 items to bind to your own mqtt server messages as shown in the OH2 examples.

Hope this explains the usage, In my explanation in the ReadMe, I am assuming that you have your own mqtt broker already running, probably a bad assumption on my part.

Let me know how you get on.

from roomba980-python.

gregorij89 avatar gregorij89 commented on August 14, 2024

Ok, now I am feeling embarrassed. I already had my MQTT up and running before I´ve started to play with your script. But somehow, the concept that the script is actually a "translator" from Roomba MQTT to another MQTT missed me.

So now, when I finally understand the usage of your script (yes, I was questioning myself Why the hell is there this script if OpenHab connects to the Roomba directly), I am able to control my Roomba from OpenHab. So thanks for your post, it clears the thing.

One more comment from my side. Is somehow possible to disable the logging to the file? I see only the possibility to specify a file, but honestly, this file will grow beyond the limits during the time (I´ve set up the script as a daemon - service, so it runs 24/7). It is producing 1.6 MB file per hour.

So thank you for your post and also for your great job.

George

from roomba980-python.

NickWaterton avatar NickWaterton commented on August 14, 2024

No Problem, chalk it up to bad documentation.

As to logging, I have had some people complain about the logging (can't help it - I'm a logger!). The file will not get too huge, it's set up to use rotating files, so each log file is limited to 2 Mbytes in size, and it only keeps the last 5 log files - total size of all the logs cannot exceed 10 MBytes.

I also run the script as a daemon, and have been running it for 18 months without any issues.

In some of my later programs, I added the option to specify 'None' for the log file, and it disables logging (but I don't think I have that feature in this one). You could try /dev/null as the file name (haven't tried it, but that is where I send things I don't want). Might not work though.

The final thing you could try, if you are willing to hack the program a bit is to find the lines:

    if arg.debug:
        log_level = logging.DEBUG
    else:
        log_level = logging.INFO

in roomba.py (or maybe Main.py I forget where this ends up) and change the log level from INFO to WARN or ERROR, then the logs would only log warnings or errors, and not info.

Or just don't care, it's only 10 Mbytes.

from roomba980-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.