Zwave (plus) devices can monitor energy.
I’ve got a similar “problem”, I’ve solved it by using rules and it is supposed to that every IR-devices (TV, Blu-ray, appletv, STB) is controlled by OpenHAB (I use HABMIN as interface). If somehow a device is not in “sync” (ex OH thinks it’s on, but it’s really off because someone push the power button on the device), if made a reset button.
Here is my setup (items and rules):
items
String IRCommand "IRCommand" {channel="broadlink:rm3:24-df-a7-42-94-79:command"}
Group:Switch:OR(ON,OFF) IRSwitches (Home, RestoreOnStartup)
Switch IR_TV_Power (IRSwitches)
Switch IR_SW_Power (IRSwitches)
String IR_SW_Hdmi (IRSwitches)
Switch IR_BR_Power (IRSwitches)
Switch IR_BR_Netflix (IRSwitches) {expire="2s, OFF"}
Switch IR_BR_Up (IRSwitches) {expire="2s, OFF"}
Switch IR_BR_Down (IRSwitches) {expire="2s, OFF"}
Switch IR_BR_Left (IRSwitches) {expire="2s, OFF"}
Switch IR_BR_Right (IRSwitches) {expire="2s, OFF"}
Switch IR_BR_Enter (IRSwitches) {expire="2s, OFF"}
Switch IR_BR_Return (IRSwitches) {expire="2s, OFF"}
Switch IR_BR_Play (IRSwitches) {expire="2s, OFF"}
Switch IR_BR_Pause (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Up (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Down (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Left (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Right (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Enter (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Return (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Play (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Pause (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Power (IRSwitches)
Switch IR_SB_0 (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_1 (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_2 (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_3 (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_4 (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_5 (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_6 (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_7 (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_8 (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_9 (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Channelup (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Channeldown (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Guide (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Recordings (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_PlayPause (IRSwitches) {expire="2s, OFF"}
Switch IR_SB_Stop (IRSwitches) {expire="2s, OFF"}
Switch IR_AT_PlayPause (IRSwitches) {expire="2s, OFF"}
Switch IR_AT_Up (IRSwitches) {expire="2s, OFF"}
Switch IR_AT_Down (IRSwitches) {expire="2s, OFF"}
Switch IR_AT_Left (IRSwitches) {expire="2s, OFF"}
Switch IR_AT_Right (IRSwitches) {expire="2s, OFF"}
Switch IR_AT_OK (IRSwitches) {expire="2s, OFF"}
Switch IR_AT_Menu (IRSwitches) {expire="2s, OFF"}
Group:Switch:OR(ON,OFF) IRScenes (Home, RestoreOnStartup)
Switch IR_Netflix (IRScenes)
Switch IR_TV (IRScenes)
Switch IR_AppleTV (IRScenes)
Switch IR_Reset_Switches (Home,RestoreOnStartup) {expire="2s, OFF"}
rules
val checkFirstS=[SwitchItem item,OnOffType command|
if (item.state != command) item.sendCommand(command)
]
rule "IR switch"
when
Member of IRSwitches received command
then
var cmd = triggeringItem.name.replace(triggeringItem.name.split("_").get(0)+"_", "").toUpperCase
if (cmd.contains("HDMI")){
cmd=cmd+triggeringItem.state
}
logInfo ("cmd",cmd)
IRCommand.sendCommand(cmd)
end
rule "Start TV Scene"
when
Member of IRScenes received command
then
switch (triggeringItem.state) {
case ON : {
checkFirstS.apply(IR_TV_Power,ON)
checkFirstS.apply(IR_SW_Power,ON)
switch (triggeringItem.name) {
case "IR_Netflix" : {
createTimer(now.plusSeconds(6), [|
checkFirstS.apply(IR_BR_Power,ON)
createTimer(now.plusSeconds(15), [|
IR_BR_Netflix.sendCommand(ON)
])
])
createTimer(now.plusSeconds(5), [|
IR_SW_Hdmi.sendCommand(3)
])
checkFirstS.apply(IR_SB_Power,OFF)
}
case "IR_TV" : {
createTimer(now.plusSeconds(6), [|
checkFirstS.apply(IR_SB_Power,ON)
])
createTimer(now.plusSeconds(5), [|
IR_SW_Hdmi.sendCommand(1)
])
checkFirstS.apply(IR_BR_Power,OFF)
}
case "IR_AppleTV" : {
createTimer(now.plusSeconds(5), [|
IR_SW_Hdmi.sendCommand(2)
])
checkFirstS.apply(IR_BR_Power,OFF)
checkFirstS.apply(IR_SB_Power,OFF)
}
}
IRScenes.allMembers.filter[name != triggeringItem.name].forEach[postUpdate(OFF)]
}
case OFF : {
switch (triggeringItem.name) {
case "IR_Netflix" : {
checkFirstS.apply(IR_BR_Power,OFF)
createTimer(now.plusSeconds(3), [|
checkFirstS.apply(IR_SW_Power,OFF)
])
createTimer(now.plusSeconds(4), [|
checkFirstS.apply(IR_TV_Power,OFF)
])
}
case "IR_TV" : {
checkFirstS.apply(IR_SB_Power,OFF)
createTimer(now.plusSeconds(3), [|
checkFirstS.apply(IR_SW_Power,OFF)
])
createTimer(now.plusSeconds(4), [|
checkFirstS.apply(IR_TV_Power,OFF)
])
}
case "IR_AppleTV" : {
createTimer(now.plusSeconds(3), [|
checkFirstS.apply(IR_SW_Power,OFF)
])
createTimer(now.plusSeconds(4), [|
checkFirstS.apply(IR_TV_Power,OFF)
])
}
}
}
}
end
rule "Reset IR switches"
when
Item IR_Reset_Switches received command ON
then
IRSwitches.allMembers.forEach[postUpdate(OFF)]
IRScenes.allMembers.forEach[postUpdate(OFF)]
end