AVS Forum banner

1 - 5 of 5 Posts

·
Registered
Joined
·
4,123 Posts
Discussion Starter #1
Hi All,

I currently use Command Fusion and have all of my devices available on Telnet. I have a Linux server which will run any VM needed for this (Linux or Windows or custom) and would like to do the following independently of Command Fusion:
1) Telnet Rules Engine (Eg. See string from Device 1 then send a telnet command to Device 2)
2) Sleep Timer (Telnet or other interface to activate and cancel from Command Fusion)

Does anyone know of any open source software that would easily do this? I can do some Python and started looking into it but seems the multithreading and socket implementation might take a while so I thought I would ask here for ideas which might be easier.
 

·
Registered
Joined
·
198 Posts
You can use OpenHAB with the TCP binding and some custom rules to accomplish this. I would recommend the 2.5.x version (currently 2.5.10) since the TCP binding has not been ported to the new 3.0.0 version yet.

You will create an items file to make the connection to your devices like this:
String myDevice1 "myDevice1 [%s]" { tcp=">[192.168.0.10:23:default]" }
String myDevice2 "myDevice2 [%s]" { tcp=">[192.168.0.11:23:default]" }

Then you will create a rules file like to received events from one device and send commands to the other:

Code:
rule "Handle Device 1 Event rule"
when
    Item myDevice1 received update
then
    var event = myDevice1.state.toString()

    switch event {
            case "device1 turned on": {
                myDevice2.sendCommand("do something on device 2")
            }
            case "device1 playing": {
                myDevice2.sendCommand("device 2:go")
            }
            .....etc...
    }
end
 

·
Registered
Joined
·
4,123 Posts
Discussion Starter #3 (Edited)
Thank you for taking the time to write such an informative answer.

So far I have installed OpenHAB 2.5 on an Arch VM and it seems to be working (Or at least it is there and looks OK on port 8080).

I need to learn the basic of OpenHAB first but looks like your example covers the rules engine part. Does this look suitable for the Sleep Timer bit?
OpenHAB2 - Generic sleep timer · GitHub

Edit: I have the TCP connections working, took me a while to realise I needed to change the global Postamble setting.
I had a look at which of my devices is supported natively by OpenHAB and it seems only the Thermostat and Lutron lighting are and the Lutron module does not seem to properly support the system I am using but the TCP support you have pointed to looks really useful. The docs suggest I can open a listening port too which will be useful for the sleep timer.

You can use OpenHAB with the TCP binding and some custom rules to accomplish this. I would recommend the 2.5.x version (currently 2.5.10) since the TCP binding has not been ported to the new 3.0.0 version yet.

You will create an items file to make the connection to your devices like this:
String myDevice1 "myDevice1 [%s]" { tcp=">[192.168.0.10:23:default]" }
String myDevice2 "myDevice2 [%s]" { tcp=">[192.168.0.11:23:default]" }

Then you will create a rules file like to received events from one device and send commands to the other:

Code:
rule "Handle Device 1 Event rule"
when
    Item myDevice1 received update
then
    var event = myDevice1.state.toString()

    switch event {
            case "device1 turned on": {
                myDevice2.sendCommand("do something on device 2")
            }
            case "device1 playing": {
                myDevice2.sendCommand("device 2:go")
            }
            .....etc...
    }
end
 

·
Registered
Joined
·
198 Posts
I need to learn the basic of OpenHAB first but looks like your example covers the rules engine part. Does this look suitable for the Sleep Timer bit?
OpenHAB2 - Generic sleep timer · GitHub
Yes that looks like a good (if not overly elaborate) example for doing timers. A very basic example would be like this:
Code:
import org.openhab.model.script.actions.Timer

var Timer timer

rule "sleep timer rule"
when
    Item ......something here
then
    timer = createTimer(now.plusSeconds(60)) [|
        logInfo("my timer", "time is up!")
    ]
end
What do you want to trigger the timer?
 

·
Registered
Joined
·
4,123 Posts
Discussion Starter #5
Yes that looks like a good (if not overly elaborate) example for doing timers. A very basic example would be like this:
Code:
import org.openhab.model.script.actions.Timer

var Timer timer

rule "sleep timer rule"
when
    Item ......something here
then
    timer = createTimer(now.plusSeconds(60)) [|
        logInfo("my timer", "time is up!")
    ]
end
What do you want to trigger the timer?
Thanks again.

I want to trigger the timer from CommandFusion (Telnet interface would be easiest which I think I can do with the TCP module). I would like to be able to read the time remaining if the timer is set and cancel the timer from CommandFusion as well.
 
1 - 5 of 5 Posts
Top