OK, so we know from this that there isn’t anything wrong with this Rule. Something is commanding one or more members of the Group which results in a change which triggers the rule.
Commands can come from the following places:
- UIs including but not limited to MainUI, BasicUI, and phone apps
- Rules
- Bindings
- Other parts of the API (REST API, karaf console, etc.)
- Access to these through the cloud connector
- Access to these through a reverse proxy or by exposing OH directly to the internet
- Someone on your LAN is messing with you
The posted rule does not appear to command these Items so we can eliminate this one rule as the source. But there could be other rules or ways that this Item gets commanded. And if you have a rule that generates the names of the Items to command it won’t necessarily show up in a search.
You’ll have to systematically eliminate each of those six possible sources for commands to the Item. Assuming the Item definitions posted are complete (i.e. no member of SonosStation is lined to a Channel and there are no Items not listed that are a member of SonosStation), 3 can be eliminated.
6 Should be easy to eliminate as a possibility. If you can’t tell from your own networking configuration, go to https://whatsmyip.org and then search for that address in https://shodan.io. That will show you what can be seen by the internet from your IP address and if OH is exposed it usually can identify that.
5 you can look at what devices are attached (under your email will be a menu named “devices”. Look for anything unexpected there.
1 and 2 will take analysis and possible systematically disabling/removing access until the behavior stops.
4 and 7 will be the hardest to find and may require setting up wireshark to capture the network traffic to the OH machine and see where the commands are coming from.
Completely off-topic, but your rule could be made significantly simpler.
If you use a String Item instead of a Number Item you can map to the Strings you need in the first place and eliminate the switch.
Selection item=RadioStationBadkamer mappings=[uit="Uit", Radio2="Radio 2", Qmusic="Qmusic", Radio10="Radio 10", Slam="Slam", Radio3="Radio 3", SkyRadio="Sky", extern="Extern"]
Then your rule could become (with a few more improvements).
//---------------------------------------------------------------------------
rules.JSRule({
//---------------------------------------------------------------------------
name: "SonesSwitchToSelected",
description: "When room radioStation changed switch to selected",
triggers: [triggers.GroupStateChangeTrigger("SonosStation")],
execute: (event) => {
// If the change was to an Item name, use it's state, otherwise keep extern or uit
let radioString = (items[event.newState] !== null) ? items[event.newState].state : event.newState;
// what if the Timer already exists?
var myTimer = actions.ScriptExecution.createTimer(time.toZDT("PT2S"), function() {
console.log("2: Geselecteerde waarde voor radioString: ", radioString);
// if the radioString is uid the command is always PAUSE, otherwise it's the radioString
let command = (radioString == "uit") ? "PAUSE" : radioString;
// If the radioString is uit the associated control Item is commanded, otherwise the favorite Item is commanded
let itemName = "SonosPlay1" + event.itemName.repalce("RadioStation", "") + (radioString == "uit") ? "Control" : "Favorite";
if(event.item.includes("HuiskamerFavorite")) itemName.replace("1", "bar"); // can be eliminated if consistent naming scheme is used
// command the Item or log if we can't handle the if the change isn't to extern
if(radioString != "extern") {
if(items[itemName] == null ) {
console.log("Geen geldig item gevonden voor: ", event.itemName);
}
else {
items[itemName].sendCommand(command);
}
}
});
}
});