I’m not sure I understand the question. Are you asking here if you could use a rule to sync a Switch (controls equipment) with another Switch (TV status)?
If yes than the answer is yes. You might also be able to use the follow profile for this.
@deibich probably has the best solution for detecting the status of the TV if the other bindings do not work.
In the rule approach have a rule that triggers when the TV status Item (let’s call it TV_Status) changes state and command the Equipment based on that state. If you split it into two rules you don’t really even need any programming language and it can be done all in the basic UI rules. One triggers when the status Item changes to ON and sends command to the equipment Switch ON and the other for OFF.
In the code tab it will look a little bit like this only simpler. In this example I have a condition but you could use a trigger of “changed to ON” and “changed to OFF” instead of the condition I had to use because it’s a number.
configuration: {}
triggers:
- id: "1"
configuration:
itemName: vCloudiness
type: core.ItemStateChangeTrigger
conditions:
- inputs: {}
id: "2"
label: vCloudiness > 50 %
configuration:
itemName: vCloudiness
state: 50 %
operator: ">"
type: core.ItemStateCondition
- inputs: {}
id: "4"
configuration:
itemName: vIsCloudy
state: ON
operator: "!="
type: core.ItemStateCondition
actions:
- inputs: {}
id: "3"
configuration:
command: ON
itemName: vIsCloudy
type: core.ItemCommandAction
configuration: {}
triggers:
- id: "1"
configuration:
itemName: vCloudiness
type: core.ItemStateChangeTrigger
conditions:
- inputs: {}
id: "4"
configuration:
itemName: vIsCloudy
state: OFF
operator: "!="
type: core.ItemStateCondition
- inputs: {}
id: "5"
configuration:
itemName: vCloudiness
state: 50 %
operator: <
type: core.ItemStateCondition
actions:
- inputs: {}
id: "3"
configuration:
command: OFF
itemName: vIsCloudy
type: core.ItemCommandAction
Note, if you go this approach you can create one rule, click the “Code” tab, copy the YAML you find there, create a new rule, click the “Code” tab and paste. Edit the ONs to OFF.
In a text based JS Scripting rule using the rule builder it would look something like (I’m being thorough and testing for NULL and UNDEF which will generate errors if attempting to command an Item with them.
rules.when().item('TV_Status').changed()
.if( event => {
return !item.TV_Status.isUninitialized
}
.then( event => {
if(!items.TV_Status.isUninitialized) {
items.Equipment_Control.sendCommand(event.newItemState);
}
// do nothing if TV_Status changed to NULL or UNDEF
}).build('TV Control');
Or to follow the two rule approach which is simpler but uses two rules.
rules.when().item('TV_Status').changed().toOn().then(sendOn().toItem('EquipmentControl')).build("TV Control ON");
rules.when().item('TV_Status').changed().toOff().then(sendOff().toItem('EquipmentControl')).build("TV Control OFF");
I don’t use profiles too much, but I think you would create the Item for the TV_Status and link the Network Binding Channel to that Switch. On the link, set the Follow profile and choose the Channel that controls the equipment. Then when the Network Binding Channel sends an ON update to the Item, that will be forwarded as a command to the equipment Channel.
One draw back to this is that it’s only one way (changes from the Equipment do not get forwarded to the Network Binding) but that’s OK in this case I think.