i learned a lot in the last view days, from all of you because here in the community are a lot of useful information für my smart home project. I was able to implement the Milight iBox2 witch the Snapshot version and so on.
But at the Moment i have a Problem with the implementation of a C++ Script as Button or Switch. But first i some words about the enviroment:
I installed OpenHabian 2 (Snapshot) on my Raspberry P 3 Model B and read out the sent codes of the Remote control of the outlets with an 433Mhz Receiver connected over GPIO of the Raspberry, than I wrote C++ Scripts (for all of the my four Outlets) to switch them on/off via 433 Mhz Transmitter - Also connected over GPIO of my RaspPi. So i have know four compiled scripts:
steuerung1.cpp
steuerung2.cpp
steuerung3.cpp
steuerung4.cpp
First Command For “switch on” Outlet #1:
sudo /wiringPi/433Utils/RPi_utils/steuerung1 1
Second For “switch off” the Outlet #1:
sudo /wiringPi/433Utils/RPi_utils/steuerung1 0
And it works very well. But now i have the Problem to integrate it to OpenHAB. I think the EXEC-Binding ist the right one, but i don’t understand, how i schould configure my Thing ans Item.
Target schould be, that i habe in my Android App an Item “Outlet #1” with two Buttons “on” and “off”. If i press “on” the first command will be execute - if I press “off” the second command is execute.
Next step is to extent it to more Outlets but this is my work to duplicate and modify the Thing and Item.
I know in this community are a lot of smart people and I am sure somebody will be able to help me I appreciate your work for this Open Source project.
thank you for your post, but I don’t unterstand your solution.
When openHAB is installed in the automated way (i.e. via apt-get) an openhab user is created and the service runs under that user.
I don’t install openHAB seperatly I used the image of Openhabian - so its running the “All-Inclusive”-Image
If the command or the called script calls sudo, make sure openhab is a member of sudoers and is configured with NOPASSWORD
in the first post I was using sudo. but i change the command to avoid problems with rights… the current command needs no password with user openhabian (default user from the openhabian-image)
I understand that the cause of my problem is located in the rights management - but your explanation don’t match with my solution. May you can add some details?
There could be a lot of things, hence the article I linked to.
Please go through the How to Debug section to identify what the problem might be. Once you know what the problem is it is a simple matter to give the openhab user the right permissions.
Hello Again,
Sorry but i guess i am to stupid for that.
I tried all point which you had written but nothing is working! The result still the same…
But i am also don’t understand this point with you rule:
I put openhab into sudoer, i make this user to the owner of the directory or the script. I don’t understand why it is not working!
So is there nobody who has realize this kind of control? I cannot believe that, that i am the only one try to control Outlets with 433mhz transmitter via GPIO?
This is the only way to get the error your script is generating when you try to execute it from openHAB.
This first step in solving an error is figuring out what the error is.
I’m sure there is but realize that anything that deals with GPIO is going to be custom and the more custom it is the more unique it becomes. When you go custom like this, while there is lots of generic help, you are largely on your own.
I understand the sense of this rule, but not, how i can implement it! May you can give me a step by step introduction or any link were i can find an itroduction.
Could you please write “ls -la” under the folder “wiringPi/433Utils/RPi_utils/” under putty and post your result here? So that we can see the permiisons of your files.
Please don’t be confused - for the several tries i changed the directory of the scripts. But via Putty with user openhabian i can execute the file like before…
Some mention form me: At the moment i have create only items - should I create also Things? How schould them looks like?
val results = executeCommandLine("/opt/raspberry-remote/steuerung1@@1", 5*1000)
instead of
val results = executeCommand( cmd, 5000 l
line. Make sure you have the EXEC binding installed.
For the permissions you have two different users, openhab and openhabian. I believe the user for your openhab installation is “openhabian”, altough the steuerung files are executable in user level, you better chown and chgrp the steuerung files file to openhabian in order for openhab to use it.
I have change the owner from Openhabian to openhab, because before it was also not working and @rlkoshak told, that die Binding is using the user openhab.
I took a look to the directory openhab2-logs/openhab.log there is a warning:
2017-06-04 15:43:28.554 [WARN ] [hab.binding.exec.handler.ExecHandler] - Couldn’t transform response because transformationService of type ‘REGEX’ is unavailable
Can this help to solve my problem or where can i find the result uf the rule?
loginfo line should write the result in opanhab.log. However maybe you should also install REGEX Transformation from paper ui-addons-transformations page as exec binding seems to have a dependency on regex transformation.
I was able to stop them with uninstalling REGEX Transformation and EXEC Binding…
So i have no idea, what is going wrong here… everything is working, only this small part makes problems…
Is there any other way to implement this Outlets, for example with pilight or something else? I guess with this way i waste time it don’t worth it.