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'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... :)
It became a bit of googling on working time 8-) for finding a solution to the problem, but in the end, you find what you are looking for

Thank you so much for all your help

Maybe the last question to you ;)

I wish I have the play button to OFF (the light turns off) and Pause button to ON (the light comes on)

Is this right

Code: Select all

KEY_PLAYPAUSE@ 1 curl "http://192.168.0.158:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=Off"
KEY_PLAYPAUSE@ 0 curl "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 »

Harlov wrote:
Nautilus wrote:
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... :)
It became a bit of googling on working time 8-) for finding a solution to the problem, but in the end, you find what you are looking for

Thank you so much for all your help

Maybe the last question to you ;)

I wish I have the play button to OFF (the light turns off) and Pause button to ON (the light comes on)

Is this right

Code: Select all

KEY_PLAYPAUSE@ 1 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=Off"
KEY_PLAYPAUSE@ 0 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=On"
I did a little test, if I have what I described above, and then It's switches on and off all the time when I press play or pause button
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 »

Are play and pause separate buttons? It would seem that either you've linked them both to this "KEY_PLAYPAUSE@" command or they send the same IR command. You need to distinguish them somehow. The number between means:
https://github.com/wertarbyte/triggerhappy wrote:A value of 1 corresponds to pressing a key, while 2 is generated by
holding it; releasing it yields a value of 0.
So what you describe above makes sense (press -> On, release -> off)

If you want to toggle from the same button, you can use

Code: Select all

KEY_PLAYPAUSE@ 1 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=Toggle"
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:Are play and pause separate buttons? It would seem that either you've linked them both to this "KEY_PLAYPAUSE@" command or they send the same IR command. You need to distinguish them somehow. The number between means:
https://github.com/wertarbyte/triggerhappy wrote:A value of 1 corresponds to pressing a key, while 2 is generated by
holding it; releasing it yields a value of 0.
So what you describe above makes sense (press -> On, release -> off)

If you want to toggle from the same button, you can use

Code: Select all

KEY_PLAYPAUSE@ 1 curl "http://192.168.0.148:8080/json.htm?type=command&param=switchlight&idx=1&switchcmd=Toggle"

Code: Select all

thd --dump /dev/input/event*

When i press play button

EV_KEY  KEY_PLAYPAUSE   1       /dev/input/event0
# KEY_PLAYPAUSE 1       command
EV_KEY  KEY_PLAYPAUSE   0       /dev/input/event0
# KEY_PLAYPAUSE 0       command

and i press pause button

EV_KEY  KEY_PLAYPAUSE   1       /dev/input/event0
# KEY_PLAYPAUSE 1       command
EV_KEY  KEY_PLAYPAUSE   0       /dev/input/event0
# KEY_PLAYPAUSE 0       command
It is the same function in both play and pause,
It works when I use Toggle, but then I can turn on and off on the same button, the idea was that it should be off when I press play,
and on when I press the pause button it may not be possible, otherwise, it works with Toggle
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 using a Harmony remote? Then you can decide which IR command play sends and which IR command pause sends. Make sure they are not the same. After this, using the Flirc configuration program you can link the IR command from "play" to a certain key (combination) and the IR command from "pause" to another key (combination).

With this kind of configuration you see a different event in the dump output when you press each button (play / pause) and can map them to Domoticz On and Off commands respectively.
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 using a Harmony remote? Then you can decide which IR command play sends and which IR command pause sends. Make sure they are not the same. After this, using the Flirc configuration program you can link the IR command from "play" to a certain key (combination) and the IR command from "pause" to another key (combination).

With this kind of configuration you see a different event in the dump output when you press each button (play / pause) and can map them to Domoticz On and Off commands respectively.

Yes, I got it to work exactly how I wanted it thanks again. The next step is that I wish to have a feature that gradually lowers the light when I press play or pause with a dimmer, you might be wondering what I should have this for, it's for my home cinema I have in the basement. I have to think a little bit with dimmer what to do.

yes I have a Harmony remote 650. I'll check on what I can do with it

Thank you very much for your help, it's 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: Yes, I got it to work exactly how I wanted it thanks again.
OK, great! :D
Harlov wrote:The next step is that I wish to have a feature that gradually lowers the light when I press play or pause with a dimmer
As long as the dimmer is controlled by Domoticz, you can create a Lua script (or maybe even a Blockly) that reacts to the switch change and starts a separate dimming script. But this script, even though it can be based on e.g. json calls to Domoticz, should be something that runs outside Domoticz if you want it to take more than a couple of seconds as Domoticz will wait for any scripts to finish before proceeding (a long running script within Domoticz will hang it)...
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest