I’m currently using FHEM (which runs great), but I like to switch. Since I use a combination of my remote control (Logitech Harmony Hub) and controlling power outlets via radio, I combined LIRC with FHEM. This was fairly easy to do, but is this also possible somehow with openHAB 2?
Why would you need LIRC when you have a Harmony Hub? openHAB 2 directly supports Harmony, so this can be nicely integrated (as long as it is ok to rely on Harmony’s “actions”).
FHEM / openHAB only supports being alerted for (current) “activities” (as far as I know)
Harmony HUB limits the number of activities to (I think) eight
Some activities are directly dependend on power outlets
The last one is critical since I need to switch the power outlet ON for a specific activity (Watch TV), but since I am not able to tell Harmony to “wait” 1-2 seconds before starting to (IR) communicate with the TV, audio etc. FHEM/openHAB is not able to switch the power outlet “ON” in time.
Again: I only want to use the Harmony remote for everything.
The only thing I could think of, would be completely discarding the “logics” used in Harmony and use openHAB for everything. Which would mean: switch to activity “Watch TV” (on Harmony) > openHAB does everything from switching on the power outlet, to switching on the devices + setting up inputs / volume etc.
Ok, thanks for the background infos.
I am not aware of any binding for LIRC, but we have an IRTrans binding waiting to be reviewed and included, see https://github.com/openhab/openhab2-addons/pull/16. Might this be an option?
You might also have a look at lirc2mqtt (https://github.com/hobbyquaker/lirc2mqtt). I have been using this quite successfully to receive remote commands received by LIRC and sent out over MQTT to OH.
Have you looked at adding delays between the harmony remote codes? This can be done by customising the activity after it’s been created. Might be worth looking at to give the TV power on command enough lead time before executing the remaining steps.
Thanks! Personally, I would prefer andy_swing’s approach, which is more controllable than creating some “indrect” workflow (assuming vs. knowing that something happened (MQTT)).
I started working on a LIRC binding for ESH this weekend. It still needs a fair bit of work before I make a pull request and there are some limitations in its current form:
TCP must be enabled via the --listen directive when starting lircd
The number of repeats is not passed to the items
It can’t transmit yet (still need to decide how to handle repeats)
This is a blessing! Sorry for not testing this yet, but I will as soon as I get to it. Is it possible to get a compiled JAR file, that I can just put into openHAB?
Hi kabili207.
Halleluja! I Would love to help test this new binding!
I was in disbelief that OH does not have a LIRC binding - after all, most devices out there in peoples home uses IR as their only way of communication.
How do I install your binding? Have you made the JAR file? if so where can i get it?
Just drop it in the addons folder and it should work. There were some breaking changes to ESH recently, so you’ll want to make sure you’re running a fairly recent nightly version of OpenHAB.
A word of caution, I will be changing the channels on the remote due to feedback on the pull request. Incoming events will be changed to a trigger channel so rules will be handled differently in the final version. I’ll post an update on how to update your rules once the final version is merged in.
Thank you for the JAR.
Got it installed, and remotes from LIRC dropped in the inbox. These in turn where added, and Things were created for each remote. Great!
I’ve been struggling with using them - but I have a lot to learn in OH2. Perhaps you could present an example or two in the README of the config needed in Items, Rules and Sitemaps for usage of your binding?
Meanwhile I’ve noticed that you have made an update to the binding on your github. Will I need a new JAR file from you, or can i upgrade from the OH2 console? (or other method) -if so could you please instruct how it’s done.
I’ve updated the JAR file in the link above. Download the new version into the addons folder. You’ll need to delete your existing remotes and re-add them because the channels have changed. You can use the example below to configure the items and rules.
rule "LIRC Test"
when
Channel 'lirc:remote:local:Samsung:event' triggered KEY_DVD
then
// Toggle base boost on the AV Receiver
sendCommand(Remote_AVReceiver, "KEY_BASEBOOST")
// Increase the volume, repeating it 4 times.
sendCommand(Remote_AVReceiver, "KEY_VOLUMEUP 4")
end
Thanks great work.
Installed the new JAR, and got OH2 receiving and sending IR signals through LIRC via your binding. Your examples was just what i needed to get started. GREAT
Keep up the good work!
Hi!
Would it be possible to use the “switch/case” approach seen in: Problem with OpenHab, Lirc, XBMC & repeats to assign function to remotes with your new binding? -this seems somewhat more tidy, when trying to get an overview.
I made an attempt at it, but have problems getting it to work. Perhaps i got it all wrong, or maybe it has to do with the format delivered by the “[marthome.event.ChannelTriggeredEvent] - lirc:remote:local:lys_master:event triggered green”.
this is my feeble attempt:
.items:
rule "Handle IR Keys"
when
Item IR_command received update
then
logInfo("IRhandler loggerKBO","Rule Handle IR activated")
switch(IR_command) {
case "blue": {
sendCommand(RelayModuleK2, ON)
postUpdate(RelayModuleK2, ON)
}
case "green": {
sendCommand(RelayModuleK3, ON)
postUpdate(RelayModuleK3, ON)
}
}
end
So when i press button “green” on the IR remote “lys_master” i get this in the log:
14:11:57.715 [INFO ] [marthome.event.ChannelTriggeredEvent] - lirc:remote:local:lys_master:event triggered green
all good, but the item “IR_command” does not get an update when the event is triggered:(
Do I need additional rule to update item?,
How do i assign the string value of the event trigger to a variable that can be used for the "switch/case"
Or is there a much simpler solution all together, to create this functionality, when 3-5 IR-remotes with 20-30 buttons each are being handled?
Eclipse Smarthome, and by extension OpenHAB, has two types of Channels: State Channels (i.e. Dimmer, Switch, String, etc.) and Trigger Channels. Only State Channels can be bound to an Item.
In your case, you’d need to modify your .rules file to look like this:
rule "Handle IR Keys"
when
Channel 'lirc:remote:local:lys_master:event' triggered
then
logInfo("IRhandler loggerKBO", "Rule Handle IR activated")
// receivedEvent contains details about the event that triggered this rule.
// Available methods on it are getEvent() and getChannel()
var buttonName = receivedEvent.getEvent()
switch(buttonName) {
case "blue": {
sendCommand(RelayModuleK2, ON)
postUpdate(RelayModuleK2, ON)
}
case "green": {
sendCommand(RelayModuleK3, ON)
postUpdate(RelayModuleK3, ON)
}
}
end
Trigger Channels are still fairly new (they were only introduced around two months ago) so documentation on how to use them properly is pretty sparse at the moment.
Sorry for digging up an old thread but it’s the only one i can find on this binding.
I’ve tried to set this up as per the instructions but i’m getting the following results.
Even though i have added the server and port remotes are not discovered. I manually setup in a .things file and when trying to send a command im getting the following in my logs.
14:56:29.502 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘GF_Living_Source’ received command 5
14:56:29.503 [ERROR] [nternal.profiles.DefaultMasterProfile] - Exception occurred while calling handler: java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:220) ~[?:?]
at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:189) ~[?:?]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:83) ~[?:?]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:67) ~[?:?]
at org.eclipse.smarthome.core.thing.internal.profiles.DefaultMasterProfile.onCommand(DefaultMasterProfile.java:49) ~[?:?]
at org.eclipse.smarthome.core.thing.internal.CommunicationManager.lambda$2(CommunicationManager.java:177) ~[?:?]
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) [?:?]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) [?:?]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) [?:?]
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) [?:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) [?:?]
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:270) [?:?]
at java.util.concurrent.ConcurrentHashMap$ValueSpliterator.forEachRemaining(ConcurrentHashMap.java:3566) [?:?]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) [?:?]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) [?:?]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) [?:?]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) [?:?]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:?]
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) [?:?]
at org.eclipse.smarthome.core.thing.internal.CommunicationManager.receiveCommand(CommunicationManager.java:172) [105:org.eclipse.smarthome.core.thing:0.9.0.201709121704]
at org.eclipse.smarthome.core.thing.internal.CommunicationManager.receive(CommunicationManager.java:91) [105:org.eclipse.smarthome.core.thing:0.9.0.201709121704]
at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:193) [98:org.eclipse.smarthome.core:0.9.0.201709121704]
at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1) [98:org.eclipse.smarthome.core:0.9.0.201709121704]
at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:181) [98:org.eclipse.smarthome.core:0.9.0.201709121704]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.NullPointerException
at org.eclipse.smarthome.binding.lirc.internal.connector.LIRCConnector.sendCommand(LIRCConnector.java:140) ~[?:?]
at org.eclipse.smarthome.binding.lirc.internal.connector.LIRCConnector.transmit(LIRCConnector.java:136) ~[?:?]
at org.eclipse.smarthome.binding.lirc.internal.connector.LIRCConnector.transmit(LIRCConnector.java:119) ~[?:?]
at org.eclipse.smarthome.binding.lirc.handler.LIRCBridgeHandler.transmit(LIRCBridgeHandler.java:166) ~[?:?]
at org.eclipse.smarthome.binding.lirc.handler.LIRCRemoteHandler.handleCommand(LIRCRemoteHandler.java:60) ~[?:?]
at org.eclipse.smarthome.core.thing.internal.profiles.DefaultMasterProfile$1.call(DefaultMasterProfile.java:52) ~[?:?]
at org.eclipse.smarthome.core.thing.internal.profiles.DefaultMasterProfile$1.call(DefaultMasterProfile.java:1) ~[?:?]
at org.eclipse.smarthome.core.common.SafeMethodCaller.executeDirectly(SafeMethodCaller.java:218) ~[?:?]
… 27 more
Anyone seen this before or know how to start fixing it?