IR Sensor on Raspberry Pi 3

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Nautilus wrote:
Harlov wrote:I think I have got it working with savings in /etc/triggerhappy/triggers.d/ but when I need to type in Domoticz

EV_KEY KEY_PLAYPAUSE 1 curl -s "http: // url: port / json.htm? Type = Command & param = Switch light & idx = IDXofNEOplug & switchcmd = On"

I get the error message in Domoticz saying Invalid ON Action!

Of course I have changed the IP ich idx
I would first verify it ( = http: // url: port / json.htm? Type = Command & param = Switch light & idx = IDXofNEOplug & switchcmd = On) works in the browser. I think it's case sensitive so the string you have there will not work like that but I'm not sure if you just wrote something there and have the correct format in the .conf file (there are also some extra spaces on your example but perhaps those are because of some copy/paste issue? :))

It could also be security (disable authentication on local network), protected switch or something like that. Check the correct json syntax here: https://www.domoticz.com/wiki/Domoticz_ ... Fswitch_on

edit: I see you edited the post but the syntax is still wrong. Should be something like:

Code: Select all

http://192.168.0.???:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On
note the added "&switchcmd
Here is the correct comands i type in it is perhaps wrong

EV_KEY KEY_PLAYPAUSE 1 curl -s "http://192.168.0.???:8080/json.htm?type ... t&idx=1=On"

aha okej
I wrote that you showed and got 401 Unauthorized
Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Nautilus wrote:
Harlov wrote:...but when I need to type in Domoticz...
This I don't quite get. You should not be typing anything in Domoticz (not sure though if I understand the sentence correctly :))...
Harlov wrote: EV_KEY KEY_PLAYPAUSE 1 curl -s "http://192.168.0.???:8080/json.htm?type ... t&idx=1=On"
EV_KEY KEY_PLAYPAUSE 1 curl -s "http://192.168.0.???:8080/json.htm?type ... &idx=1=Off"
Also, why are you trying to link both On and Off to same ir command? :)

Wrong of me, I'm tired so that's probably why I can not think right
may try more tomorrow and see if I can get it to work, I get hope

Thank you for your help is appreciated
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Nautilus »

Harlov wrote:
Wrong of me, I'm tired so that's probably why I can not think right
may try more tomorrow and see if I can get it to work, I get hope

Thank you for your help is appreciated
Don't worry, you are close :) For the "unauthorized", either disable authentication in local network (Domoticz settings -> System -> Local networks) or if you use basic authentication this should also work:

Code: Select all

http://username:[email protected].???:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On
Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Nautilus wrote:
Harlov wrote:
Wrong of me, I'm tired so that's probably why I can not think right
may try more tomorrow and see if I can get it to work, I get hope

Thank you for your help is appreciated
Don't worry, you are close :) For the "unauthorized", either disable authentication in local network (Domoticz settings -> System -> Local networks) or if you use basic authentication this should also work:

Code: Select all

http://username:[email protected].???:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On
I turned off Authentication: and added the Local Networks IP number 192.168.0.* And then it works as it should when I test in the browser :D :D But it does work not when I press on the remote control :cry: it may have to do with triggerhappy, I do not know.

Code: Select all

http://192.168.0.???:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On

Code: Select all

{
   "status" : "OK",
   "title" : "SwitchLight"
}
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Nautilus »

Harlov wrote: I turned off Authentication: and added the Local Networks IP number 192.168.0.* And then it works as it should when I test in the browser :D :D
Well, you can keep the authentication on, just keep the bypass for local network the you've set it up now. If you have opened the Domoticz port to outside network (and forwarded the IP) then anyone can access it...:)
Harlov wrote:But it does work not when I press on the remote control :cry: it may have to do with triggerhappy, I do not know.

Code: Select all

http://192.168.0.???:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On
I trust you reloaded Triggerhapppy after modifying the .conf file? If not, please do and test again. Also, are you 100% sure the remote's keypress is interpreted as "EV_KEY KEY_PLAYPAUSE"? It was what you saw when running the "dump" command?
Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Nautilus wrote:
Harlov wrote: I turned off Authentication: and added the Local Networks IP number 192.168.0.* And then it works as it should when I test in the browser :D :D
Well, you can keep the authentication on, just keep the bypass for local network the you've set it up now. If you have opened the Domoticz port to outside network (and forwarded the IP) then anyone can access it...:)
Harlov wrote:But it does work not when I press on the remote control :cry: it may have to do with triggerhappy, I do not know.

Code: Select all

http://192.168.0.???:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On
I trust you reloaded Triggerhapppy after modifying the .conf file? If not, please do and test again. Also, are you 100% sure the remote's keypress is interpreted as "EV_KEY KEY_PLAYPAUSE"? It was what you saw when running the "dump" command?

I did a reload of TriggerHappy but nothing happens when I press any buttons

Code: Select all

EV_KEY  KEY_PLAYPAUSE 1 curl -s "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1=On"

Code: Select all

EV_KEY  KEY_PLAYPAUSE   1       /dev/input/event0
# KEY_PLAYPAUSE 1       command
EV_KEY  KEY_PLAYPAUSE   0       /dev/input/event0
# KEY_PLAYPAUSE 0       command
but nothing happens
Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Harlov wrote:
Nautilus wrote:
Harlov wrote: I turned off Authentication: and added the Local Networks IP number 192.168.0.* And then it works as it should when I test in the browser :D :D
Well, you can keep the authentication on, just keep the bypass for local network the you've set it up now. If you have opened the Domoticz port to outside network (and forwarded the IP) then anyone can access it...:)
Harlov wrote:But it does work not when I press on the remote control :cry: it may have to do with triggerhappy, I do not know.

Code: Select all

http://192.168.0.???:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On
I trust you reloaded Triggerhapppy after modifying the .conf file? If not, please do and test again. Also, are you 100% sure the remote's keypress is interpreted as "EV_KEY KEY_PLAYPAUSE"? It was what you saw when running the "dump" command?

I did a reload of TriggerHappy but nothing happens when I press any buttons

Code: Select all

EV_KEY  KEY_PLAYPAUSE 1 curl -s "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1=On"

Code: Select all

EV_KEY  KEY_PLAYPAUSE   1       /dev/input/event0
# KEY_PLAYPAUSE 1       command
EV_KEY  KEY_PLAYPAUSE   0       /dev/input/event0
# KEY_PLAYPAUSE 0       command
but nothing happens

Is it because I use the Logitech Harmony 650 remote makes it not work
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Nautilus »

Harlov wrote: Is it because I use the Logitech Harmony 650 remote makes it not work
No, I think it is the "key name" that is wrong. Let me give you an example. When I turn on the "dump" and press a certain key I get:

Code: Select all

EV_KEY	KEY_LEFTCTRL	1	/dev/input/event1
# KEY_LEFTCTRL	1	command
EV_KEY	KEY_LEFTSHIFT	1	/dev/input/event1
# KEY_LEFTCTRL+KEY_LEFTSHIFT	1	command
EV_KEY	KEY_2	1	/dev/input/event1
# KEY_LEFTCTRL+KEY_LEFTSHIFT+KEY_2	1	command
EV_KEY	KEY_2	2	/dev/input/event1
# KEY_LEFTCTRL+KEY_LEFTSHIFT+KEY_2	2	command
EV_KEY	KEY_LEFTCTRL	0	/dev/input/event1
# KEY_2+KEY_LEFTSHIFT+KEY_LEFTCTRL	0	command
EV_KEY	KEY_LEFTSHIFT	0	/dev/input/event1
# KEY_2+KEY_LEFTSHIFT	0	command
EV_KEY	KEY_2	0	/dev/input/event1
# KEY_2	0	command
So the dump outputs all of the above. From all these, the correct line in my .conf file is just:

Code: Select all

KEY_2+KEY_LEFTSHIFT+KEY_LEFTCTRL 1 curl -s "http://url:port/json.htm?type=command&param=switchlight&idx=356&switchcmd=On"
So I'd drop the EV_KEY away at least and try with just:

Code: Select all

KEY_PLAYPAUSE 1 curl -s "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1=On"
Remember to reload...:)
Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Nautilus wrote:
Harlov wrote: Is it because I use the Logitech Harmony 650 remote makes it not work
No, I think it is the "key name" that is wrong. Let me give you an example. When I turn on the "dump" and press a certain key I get:

Code: Select all

EV_KEY	KEY_LEFTCTRL	1	/dev/input/event1
# KEY_LEFTCTRL	1	command
EV_KEY	KEY_LEFTSHIFT	1	/dev/input/event1
# KEY_LEFTCTRL+KEY_LEFTSHIFT	1	command
EV_KEY	KEY_2	1	/dev/input/event1
# KEY_LEFTCTRL+KEY_LEFTSHIFT+KEY_2	1	command
EV_KEY	KEY_2	2	/dev/input/event1
# KEY_LEFTCTRL+KEY_LEFTSHIFT+KEY_2	2	command
EV_KEY	KEY_LEFTCTRL	0	/dev/input/event1
# KEY_2+KEY_LEFTSHIFT+KEY_LEFTCTRL	0	command
EV_KEY	KEY_LEFTSHIFT	0	/dev/input/event1
# KEY_2+KEY_LEFTSHIFT	0	command
EV_KEY	KEY_2	0	/dev/input/event1
# KEY_2	0	command
So the dump outputs all of the above. From all these, the correct line in my .conf file is just:

Code: Select all

KEY_2+KEY_LEFTSHIFT+KEY_LEFTCTRL 1 curl -s "http://url:port/json.htm?type=command&param=switchlight&idx=356&switchcmd=On"
So I'd drop the EV_KEY away at least and try with just:

Code: Select all

KEY_PLAYPAUSE 1 curl -s "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1=On"
Remember to reload...:)
Tried to switch to without EV_KEY but nothing happens. I also did reload twice but nothing works, your code looks after all begin the same way as my codes so then you might wonder what is wrong

Code: Select all

KEY_PLAYPAUSE 1 curl -s http://
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Nautilus »

Hmm, strange indeed. Only couple of things left to try I think.

==========
EDIT:Maybe just a typo in your post above, but after posting this I noticed the command below is still faulty, it is missing the &switchcmd part, i.e. should be: curl -s "http://192.168.0.148:8080/json.htm?type ... ]switchcmd[/b]=On"
==========

1. From command line run the curl command and see if it goes through as expected. I mean:

Code: Select all

curl -s "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1=On"
Note! Copy/paste it from the .conf file so that you use the exact same format. If this triggers the desired action in Domoticz, then this part certainly works.

2. Choose another IR command and this time use the full keyboard in Flirc and associate the IR command to some simple key combination. E.g. what I used in my example CTRL+ALT+2. Now that you are not using a normal keyboard key it might cause some issues.

If 1. fails, then we need to try to fix that before moving to 2. Post any error messages you might get here...:)
Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Nautilus wrote:Hmm, strange indeed. Only couple of things left to try I think.

==========
EDIT:Maybe just a typo in your post above, but after posting this I noticed the command below is still faulty, it is missing the &switchcmd part, i.e. should be: curl -s "http://192.168.0.148:8080/json.htm?type ... ]switchcmd[/b]=On"
==========

1. From command line run the curl command and see if it goes through as expected. I mean:

Code: Select all

curl -s "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1=On"
Note! Copy/paste it from the .conf file so that you use the exact same format. If this triggers the desired action in Domoticz, then this part certainly works.

2. Choose another IR command and this time use the full keyboard in Flirc and associate the IR command to some simple key combination. E.g. what I used in my example CTRL+ALT+2. Now that you are not using a normal keyboard key it might cause some issues.

If 1. fails, then we need to try to fix that before moving to 2. Post any error messages you might get here...:)
I changed the conf file and made a reload and this is the result

What this how you meant

Code: Select all

pi@raspberrypi:~ $ curl -s http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On
[1] 858
[2] 859
[3] 860
pi@raspberrypi:~ $ {
   "status" : "ERR"
}
^C
[1]   Done                    curl -s http://192.168.0.148:8080/json.htm?type=command
[2]-  Done                    param=switchlight
[3]+  Done                    idx=1
pi@raspberrypi:~ $
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Nautilus »

You are missing quotes around the url ->

Code: Select all

"http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On"
Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Nautilus wrote:You are missing quotes around the url ->

Code: Select all

"http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On"
then i got this

Code: Select all

pi@raspberrypi:~ $ curl -s "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On"
pi@raspberrypi:~ $
in the browser

Code: Select all

{
   "status" : "OK",
   "title" : "SwitchLight"
}
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Nautilus »

Take away -s (s = silent) and you should see some output. In any case, you can check from Domoticz log (switch log) if it fired.
Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Nautilus wrote:Take away -s (s = silent) and you should see some output. In any case, you can check from Domoticz log (switch log) if it fired.
Log file Domoticz

Code: Select all

2017-03-15 23:27:03.632 OpenZWave: Domoticz has send a Switch command! NodeID: 4 (0x04)
2017-03-15 23:27:03.632 (Controller) Light/Switch (Wall Plug)
2017-03-15 23:27:03.685 (Controller) Light/Switch (Wall Plug)
2017-03-15 23:27:03.703 (Controller) Light/Switch (Wall Plug)
2017-03-15 23:27:11.472 Incoming connection from: 192.168.0.106
And this

Code: Select all

pi@raspberrypi:~ $ curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On"
{
   "status" : "OK",
   "title" : "SwitchLight"
}
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Nautilus »

Ok, curl is finally working. Did you already try it in the .conf file in the correct format? :)
Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Nautilus wrote:Ok, curl is finally working. Did you already try it in the .conf file in the correct format? :)
I have saved this in the conf file and make reload
so it seems EV_KEY_KEY_PLAYPAUSE do not want to work
it might be something wrong with the infrared usb?

Code: Select all

EV_KEY_KEY_PLAYPAUSE 1 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On"
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Nautilus »

Harlov wrote:
Nautilus wrote:Ok, curl is finally working. Did you already try it in the .conf file in the correct format? :)
I have saved this in the conf file and make reload
so it seems EV_KEY_KEY_PLAYPAUSE do not want to work
it might be something wrong with the infrared usb?

Code: Select all

EV_KEY_KEY_PLAYPAUSE 1 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On"
As discussed, I'm pretty sure it needs to be:

Code: Select all

KEY_PLAYPAUSE 1 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On"
But if this does not work, then go for point number 2. from the earlier post and try with a standard key (combination)...
Harlov
Posts: 24
Joined: Sunday 12 March 2017 1:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Harlov »

Nautilus wrote:
Harlov wrote:
Nautilus wrote:Ok, curl is finally working. Did you already try it in the .conf file in the correct format? :)
I have saved this in the conf file and make reload
so it seems EV_KEY_KEY_PLAYPAUSE do not want to work
it might be something wrong with the infrared usb?

Code: Select all

EV_KEY_KEY_PLAYPAUSE 1 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On"
As discussed, I'm pretty sure it needs to be:

Code: Select all

KEY_PLAYPAUSE 1 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On"
But if this does not work, then go for point number 2. from the earlier post and try with a standard key (combination)...
I've got it working now, I had to put a @ after KEY_PLAYPAUSE@ . I also had to modify the configuration files in it's default setup, the daemon is run as user nobody and i have Changing the user to pi, and then restart and it worked :D

Code: Select all

KEY_PLAYPAUSE@ 1 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=Off"
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: IR Sensor on Raspberry Pi 3

Post by Nautilus »

Harlov wrote: I've got it working now, I had to put a @ after KEY_PLAYPAUSE@ . I also had to modify the configuration files in it's default setup, the daemon is run as user nobody and i have Changing the user to pi, and then restart and it worked :D

Code: Select all

KEY_PLAYPAUSE@ 1 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=Off"
Good to hear! Was a bit of a struggle but you pulled it through... :)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest