Openhab 2 exec binding 2.0 configuration

Ok, here we go. That configuration allows me to start my NAS using the Amazon Echo and it actually represents the current state of the switch by querying if the device is online:

.things
Thing exec:command:device-nas-control “NAS Control Command” [ command="/home/openhab/bin/device-nas %2$s", interval=0, timeout=10, autorun=true ]
Thing exec:command:device-nas-status “NAS State Command” [ command="/home/openhab/bin/device-nas status", interval=20, timeout=5 ]

.items
String network_device_nas_control “NAS Control” { channel=“exec:command:device-nas-control:input”, channel=“exec:command:device-nas-status:output”, autoupdate=“false” }
String network_device_nas_status “NAS Status” { channel=“exec:command:device-nas-status:output” }
Switch network_device_nas_switch “NAS” (group_location_livingroom) [ “Switchable” ]

.sitemap
Switch item=network_device_nas_switch

.rules

rule "NAS Switch"
when
    Item network_device_nas_switch changed
then
    logInfo("Network", "Switching NAS " + network_device_nas_switch.state.toString + ": " + network_device_nas_control.state.toString)
    network_device_nas_status.postUpdate(network_device_nas_switch.state.toString)
    network_device_nas_control.sendCommand(network_device_nas_switch.state.toString)
end

rule "NAS State"
when
    Item network_device_nas_status changed
then
    logInfo("Network", "Switching NAS " + network_device_nas_status.state.toString + ": " + network_device_nas_control.state.toString)
    network_device_nas_switch.postUpdate(network_device_nas_status.state.toString)
    network_device_nas_control.sendCommand(network_device_nas_status.state.toString)
end
1 Like