Mercedes Benz integration

Hello, can someone tell me how exactly do I start the script automatically? I have no experience with the exec addon.

Hey Hans,
you will find a rules file in my data. In this file there is already an exec command rule as an example.
To make it work you have to install the exec binding and put the executable command in the exec.whitlist file (misc folder).

so for my example the whole thing looks like this:

openhabconf/misc/exec.whitelist

/usr/bin/python3 /etc/openhab/scripts/mb-connect/mb-connect.py --data

hope this helps

Chris

Ok, and do I have to configure something in the Exec Addon? Or just add to the whitelist?

1 Like

This is the Log after putting

/usr/bin/python3 /etc/openhab/scripts/mb-connect/mb-connect.py --data
 in the Whitelist


2021-03-01 17:45:29.482 [WARN ] [ng.exec.internal.handler.ExecHandler] - Tried to execute 'Duration.ofSeconds(45),"/usr/bin/python3", "/etc/openhab/scripts/mb-connect/mb-connect.py", "--data"', but it is not contained in whitelist.

Are you sure you created the whitlist file correctly?
Correct folder, correct content?

Maybe the exec binding or openHAB has to be restarted once.

It doesn’t work for me, I restarted openHAB. the exec.whitelist in the path etc/openhab/misc has the following content 
 /usr/bin/python3 /etc/openhab/scripts/mb-connect/mb-connect.py --data

the enclosed rule starts, but does not update the items. if I enter manually python3 etc/openhab/scripts/mb-connect/mb-connect.py --data via putty, everything works.

Hi Skynet
 I guess that you only have openhab2 ??
The syntax used in rule file is for openhab3 ??

No, i use openHAB 3

mabye there is a problem with the file permission?
try tu run the mb-connect.py with the same user as openhab in the putty terminal and check the result.

Yes this works without problems


Since my script works for you, the problem seems to be more with the configuration of the Exec binding.
If you still have the error message with the whitlist,

you should look for the error at this point.
Maybe read again the description of exec binding, which I have already listed.

Edit the whitelist-file:

nano /etc/openhab/misc/exec.whitelist

Add this line:

python /etc/openhab/scripts/mb-connect/mb-connect.py --data

Restart OH

This should solve the error (except you put the script somewhere else or reference python directly.

No i give it up The automatic execution does not work on my system. I have now tried for several days to have the script run automatically. Manually it works without problems just so it is of no use to me. Thanks for the answers


Hi Chris,
absolutely great to hear that you managed connecting to your MB. Here is another idea what to do with it:
display your daily CO2 footprint fully automated. it just needs to know the fuel level in your tank and the mileage. As my Mercedes is a bit too old for online connection, I had to use a OBD II and an ESP - not needed with your solution. Hope some others will pick up your and my idea and get a good feeling of their personal CO2 footprint

1 Like

Hey, @vfebert
glad you like it.

This is a really good idea and is definitely on my list.

Hey @Skynet86 ,
Have you ever checked your linux file permissions?

Maybe that’s where it comes from. Make sure that the mb-connect.py file is executable by the user running openhab.

Hi @spawny0815 ,
first thanks for all the good work.
I followed your instructions. However, when trying to run the script

pip3 install -r requirements.txt

I get the error

Invalid requirement: '<!DOCTYPE html>'
Traceback (most recent call last):
  File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/requirements.py", line 93, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1632, in parseString
    raise exc
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1622, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1379, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 3395, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1379, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 3717, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1379, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 3378, in parseImpl
    loc, resultlist = self.exprs[0]._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1383, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 2689, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected W:(abcd...) (at char 0), (line:1, col:1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_internal/req/constructors.py", line 253, in install_req_from_line
    req = Requirement(req)
  File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/requirements.py", line 97, in __init__
    requirement_string[e.loc : e.loc + 8], e.msg
pip._vendor.packaging.requirements.InvalidRequirement: Parse error at "'<!DOCTYP'": Expected W:(abcd...)

Any help?
Thanks, Thomas

make sure you execute the script in the folder where the file is.

  • Example: cd /etc/openhab/scripts/mb-connect/ && pip3 install -r requirements.txt

Thanks for the quick help. This is what I did :frowning:

openhabian@openhabian:~ $ cd /etc/openhab/scripts/mb-connect/ && pip3 install -r requirements.txt
Invalid requirement: '<!DOCTYPE html>'
Traceback (most recent call last):
  File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/requirements.py", line 93, in __init__
    req = REQUIREMENT.parseString(requirement_string)
...

are you sure you copied the files to that location? Also, can you try to get to the folder one step after the other just to make sure you are really in the folder
 that is what i did.

cd etc
cd openhab
cd scripts
cd mb-connect

once you are in the folder mb-connect, run the command:

pip3 install -r requirements.txt