Crazy !!! echo ‘SEND_ONCE harman-kardon KEY_POWER’ | nc localhost 8765 works also, now !!
Ok interesting I wonder if you had something else running on 9001 and you were getting a conflict.
Test using
nc localhost 8765
then typing your SEND_ONCE command and hitting enter
Guy, you are a god, openhab works also !!!
Cool, port conflict you have something else running on 9001, see it’s still in the list.
Now change your openhab server config to 8765
SEND_ONCE harman-kardon KEY_POWER
BEGIN
SEND_ONCE harman-kardon KEY_POWER
SUCCESS
END
Everything’s working ! Including the controlling in openhab !! Oh my god, I thank you so much !
your very welcome. Now it’s just a matter of tweaking your rules and sitemap to your liking.
Let me know if you have any problems.
Hi there again,
I thought about making a rule that makes a sequence of different commands, in my case: Turn the receiver on and navigate through the home screen of my Apple TV, click on Netflix and start a movie.
In sitemaps, everything works great. In the rule “Sheldon” all commands are executes many times. There is something like a permanent rule that can only stop by updating the files. When I only write one single operation in the rule, this works. When writing two or more commands, they were permanently repeated. It seems that the Threat sleep has something to do with the interval of the repeats.
Can anyone help me, maybe you, @chriscolden, again ?
Thank you !
The rule looks like this:
rule "Sheldon"
when Item sheldon received command
then if(receivedCommand == ON)
Power_Plug_Socket_B9.sendCommand("ON") // turn on the socket
Thread::sleep(5000)
lirc.apply("fernseher", "KEY_POWER", logName) // turn on the tv
Thread::sleep(1600)
lirc.apply("appletv", "KEY_UP", logName) // random button to turn the Apple TV on
Thread::sleep(25000)
lirc.apply("harman_kardon", "KEY_POWER", logName) // turn on the receiver
Thread::sleep(25000)
lirc.apply("appletv", "KEY_DOWN", logName) // navigate in the home screen
Thread::sleep(1600)
lirc.apply("appletv", "KEY_DOWN", logName) // navigate in the home screen
sheldon.sendCommand("OFF")
end
The rule of the virtual remote in sitemap is:
import org.eclipse.xtext.xbase.lib.Functions
val logName = "Media"
val Functions$Function3<String, String, String, Boolean> lirc= [ r, k, ln |
logInfo(ln, "LIRC Send " + r + " " + k)
sendCommand("Remote_" + r, k)
true
]
rule "Harman Kardon"
when
Item HarmanKardon received command
then
if (receivedCommand == 1) lirc.apply("harman_kardon", "KEY_POWER", logName)
if (receivedCommand == 2) lirc.apply("harman_kardon", "KEY_POWER2", logName)
.....
if (receivedCommand == 10) lirc.apply("appletv", "KEY_UP", logName)
if (receivedCommand == 11) lirc.apply("appletv", "KEY_DOWN", logName)
if (receivedCommand == 12) lirc.apply("appletv", "KEY_LEFT", logName)
if (receivedCommand == 13) lirc.apply("appletv", "KEY_RIGHT", logName)
if (receivedCommand == 14) lirc.apply("appletv", "KEY_MENU", logName)
......
end
The items file is:
Switch Remote_Send { channel="exec:command:remote-send:run" }
String Remote_Send_Args { channel="exec:command:remote-send:input"}
String Remote_Send_Out { channel="exec:command:remote-send:output" }
Group remotes
Number HarmanKardon "" <none> (gLounge) { autoupdate="false" }
String Remote_harman_kardon { channel="lirc:remote:local:harman-kardon:transmit" }
Number appletv "" <none> (gLounge) { autoupdate="false" }
String Remote_appletv { channel="lirc:remote:local:appletv:transmit" }
Number fernseher "" <none> (gLounge) { autoupdate="false" }
String Remote_fernseher { channel="lirc:remote:local:fernseher:transmit" }
Number ledstrip "" <none> (gLounge) { autoupdate="false" }
String Remote_ledstrip { channel="lirc:remote:local:ledstrip:transmit" }
The things file is:
Bridge lirc:bridge:local [ host="***myIP***", port="8765" ] {
Thing remote harman-kardon [ remote="Harman-Kardon" ]
Thing remote appletv [ remote="appletv" ]
Thing remote fernseher [ remote="fernseher" ]
Thing remote ledstrip [ remote="ledstrip" ]
}
oh god, thats embarrassing, I’ve forgotten the brackets in the rule. The rule repeats itself after the first cycle and ends in a permanent slope.
The right rule is:
rule "Sheldon"
when Item sheldon received command
then if(receivedCommand == ON)
{
Power_Plug_Socket_B9.sendCommand("ON") // turn on the socket
Thread::sleep(5000)
lirc.apply("fernseher", "KEY_POWER", logName) // turn on the tv
Thread::sleep(1600)
lirc.apply("appletv", "KEY_UP", logName) // random button to turn the Apple TV on
Thread::sleep(25000)
lirc.apply("harman_kardon", "KEY_POWER", logName) // turn on the receiver
Thread::sleep(25000)
lirc.apply("appletv", "KEY_DOWN", logName) // navigate in the home screen
Thread::sleep(1600)
lirc.apply("appletv", "KEY_DOWN", logName) // navigate in the home screen
sheldon.sendCommand("OFF")
}
end
I would make some changes. So have the switch item of sheldon {autoupdate=false}
Then on the rule for sheldon have received command ON
Do away with your if ON and remove the send command off.
You can add a lock to avoid it executing concurrently. This explains them well Explain lock() command?
Thank you for the advise, @chriscolden, I am going to read the discussion in near future The first impress of the idea is interesting.
I was on my phone before but so you know this is the example. I’ll leave the lock up to you if you need it or not.
item receives the ON command and the rule fires
rule "Sheldon"
when Item sheldon received command ON
then
Power_Plug_Socket_B9.sendCommand("ON") // turn on the socket
Thread::sleep(5000)
lirc.apply("fernseher", "KEY_POWER", logName) // turn on the tv
Thread::sleep(1600)
lirc.apply("appletv", "KEY_UP", logName) // random button to turn the Apple TV on
Thread::sleep(25000)
lirc.apply("harman_kardon", "KEY_POWER", logName) // turn on the receiver
Thread::sleep(25000)
lirc.apply("appletv", "KEY_DOWN", logName) // navigate in the home screen
Thread::sleep(1600)
lirc.apply("appletv", "KEY_DOWN", logName) // navigate in the home screen
}
end
add autoupdate false to your sheldon item which causes it to not update its state, so you don’t have to turn it off.
{autoupdate=“false”}
Hey again, I tried to get it to work on an other pi. I’m confused because I can’t find the .service file under /usr/lib/systemd/system/lirc.service. Do you have an idea, where it is ? @chriscolden
Not sure to be honest.
Don’t think i’ve upgraded mine in a while. it’s using init.d (/etc/init.d/lirc)
pi@GB-SL-RPI02:/lib/systemd/system $ sudo systemctl status lirc
● lirc.service - LSB: Starts LIRC daemon.
Loaded: loaded (/etc/init.d/lirc)
Active: active (running) since Thu 2018-04-12 21:17:13 BST; 1 weeks 5 days ago
Process: 415 ExecStart=/etc/init.d/lirc start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/lirc.service
└─484 /usr/sbin/lircd --driver=default --device=/dev/lirc0 --uinput --listen=8765
Thats what I get ( note the “d” in in “lircd” in the first line ):
/lib/systemd/system$ sudo systemctl status lircd
● lircd.service - Flexible IR remote input/output application support
Loaded: loaded (/lib/systemd/system/lircd.service; enabled; vendor preset:
Active: active (running) since Wed 2018-04-25 08:41:01 CEST; 11h ago
Docs: man:lircd(8)
http://lirc.org/html/configure.html
Main PID: 595 (lircd)
CGroup: /system.slice/lircd.service
└─595 /usr/sbin/lircd --nodaemon
Apr 25 08:41:02 openHABianPi lircd[595]: lircd-0.9.4c[595]: Notice: accepted n
Apr 25 08:41:02 openHABianPi lircd-0.9.4c[595]: Notice: lircd(default) ready,
Apr 25 08:41:02 openHABianPi lircd-0.9.4c[595]: Notice: accepted new client on
Apr 25 08:41:02 openHABianPi lircd-0.9.4c[595]: Info: Cannot configure the rc
Apr 25 08:41:02 openHABianPi lircd-0.9.4c[595]: Notice: accepted new client on
Apr 25 08:41:02 openHABianPi lircd-0.9.4c[595]: Notice: accepted new client on
Apr 25 08:45:14 openHABianPi lircd[595]: lircd-0.9.4c[595]: Notice: accepted n
Apr 25 08:45:14 openHABianPi lircd-0.9.4c[595]: Notice: accepted new client on
Apr 25 08:45:14 openHABianPi lircd[595]: lircd-0.9.4c[595]: Info: removed clie
Apr 25 08:45:14 openHABianPi lircd-0.9.4c[595]: Info: removed client
ESC
Also, you see the “–nodeamon”. That’s the problem - I have to get lirc(d) listening to a port … I don’t know where to modify that.
/lib/systemd/system/lircd.service is your service file.
previously i think you were looking in /usr/lib/systemd/system/lirc.service
I thank you so much, man ! You helped me the second time. I wish I could help you once, too. Thanks a lot !!
Your welcome. People have helped me loads, great to be able to help others.
Hey everyone
I have been trying my best to get this working and I cant, I have written my own remote code and added it to /etc/lirc/lircd.conf.d and name it RGB.lirc.conf.i am trying to control my RGB led light throw OH2 installed on RPI3 with LIRC and it works fine when I send I receive on terminal ssh, I have followed the openhab2 guide for addon LIrc as Binding and here is what my files looks like and not sure what im missing, im new to coding and all this stuff… THANKS in advance for any help
rule "Temote"
when
Item GF_Remote received command
then
if (receivedCommand == 1)
{
lirc.apply("RGB", "KEY_R", logName)
}
else
{
lirc.apply("RGB", "KEY_B", logName)
}
end
items:
Number GF_Remote "" <none> (gLounge) { autoupdate="false" }
String Remote_RGB { channel="lirc:remote:local:RGB:transmit" }
things:
Bridge lirc:bridge:local [ host="192.168.2.97", port="8765" ] {
Thing remote RGB [ remote="RGB" ]
}
I don’t have sitemaps file for this and I am trying to use Habpanel in the future and maybe paperUI for now… everything on terminal works fine even the echo command, with the files I have I don’t have a switch so im wondering if I need one and how ? please help me fix this ?
It looks like you’re trying to use a lambda expression in your rule, but you haven’t defined it anywhere. If you want to get this working without the lambda, you can use this for your rule:
rule "Temote"
when
Item GF_Remote received command
then
if (receivedCommand == 1)
{
sendCommand(Remote_RGB, "KEY_R")
}
else
{
sendCommand(Remote_RGB, "KEY_B")
}
end
I tried this and still not working.
i am only trying to press a button from HABPANEL to switch my LED LIGHT to different color . i don’t seem to have the right code yet. i have my things discovered my RGB remote and i added things to be a button and when i press it nothing happens. do i need Switch in my item file instead String ??
thanks in advanced for any help