[Solved] Rules trying to learn

And what does your events.log show you happening to your Item?

Bad syntax - there are no == symbols in Item based triggers.
You perhaps want changed to

rule "Sonos plays"

when
Item Sonos_stue_Controller received update // or use changed to PLAY
then
    if(Sonos_stue_Controller.state == PLAY){
        marantz_power.sendCommand(ON) 
        marantz_input.sendCommand("CD") // not sure about the CD part??
}
end

I guess the last part should be marantz_input.sendCommand("CD"), it’s a string item after all.

CD is the name of the reciever input.

I edited the rule so give it a try and see what happens. Also try changed to PLAY if received update does not work.

@BDE

Could you please use “code fences” for better reading?

Thanks a lot.

e.g. your last post would look like:

Switch marantz_power    "Receiver"    {channel="denonmarantz:avr:0006782c375f:general#power"}
Dimmer marantz_volume   "Volume"      {channel="denonmarantz:avr:0006782c375f:mainZone#volume"}
Number marantz_volumeDB "Volume [%.1f dB]" {channel="denonmarantz:avr:0006782c375f:mainZone#volumeDBe"}
Switch marantz_mute     "Mute"        {channel="denonmarantz:avr:0006782c375f:mainZone#mute"}
Switch marantz_z2power  "Zone 2"      {channel="denonmarantz:avr:006782c375f:zone2#power"}
String marantz_input    "Input [%s]"  {channel="denonmarantz:avr:0006782c375f:mainZone#input" }
String marantz_surround "Surround: [%s]" {channel="denonmarantz:avr:0006782c375f:general#surroundProgram"}
String marantz_command                {channel="denonmarantz:avr:0006782c375f:general#command"}
1 Like

@BDE I see you have another post about rules. I recommend starting small with one or two items first. Then expand with more rules after you get a better understanding of how to write them.

Now it looks like this. No log errors ,but reciever doesnt turn on

when
Item Sonos_stue_Controller received update PLAY
then
    if(Sonos_stue_Controller.state == PLAY){
        marantz_power.sendCommand(ON) 
        marantz_input.sendCommand("CD")
}
end

@H102 Yes just realized that. One step at the time

@Celaeno1 DONE

1 Like

Did you try:

Item Sonos_stue_Controller changed to PLAY

Also, can you turn on the receiver via BasicUI to verify that it does work with OH?

yes and yes.

OK so the issue is with the trigger. What do you see in the logs for the sonos status when it changes? Please post the actual log.

ok

2020-03-08 16:35:04.084 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from PLAY to PAUSE

2020-03-08 16:35:05.520 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from PAUSE to UNDEF

2020-03-08 16:35:07.098 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from UNDEF to PLAY

2020-03-08 16:35:20.750 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_currentartist changed from Isam B to Burhan G

2020-03-08 16:35:20.755 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_currentalbum changed from Lost For Words to Pas På Pigerne

2020-03-08 16:35:20.757 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_currenttitle changed from Life to Nathalia

2020-03-08 16:35:20.762 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from PLAY to PAUSE

2020-03-08 16:35:21.011 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from PAUSE to UNDEF

2020-03-08 16:35:21.772 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_currentalbumart changed from raw type (image/jpeg): 52024 bytes to raw type (image/jpeg): 73920 bytes

2020-03-08 16:35:23.712 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from UNDEF to PAUSE

2020-03-08 16:35:23.941 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from PAUSE to UNDEF

2020-03-08 16:35:24.927 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from UNDEF to PLAY

2020-03-08 16:35:28.914 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from PLAY to PAUSE

2020-03-08 16:35:29.237 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from PAUSE to UNDEF

2020-03-08 16:35:29.860 [vent.ItemStateChangedEvent] - sonos_CONNECT_RINCON_000E58AACE2201400_control changed from UNDEF to PLAY

Try this:

rule "Sonos plays"

when
Item sonos_CONNECT_RINCON_000E58AACE2201400_control changed
then
    if(sonos_CONNECT_RINCON_000E58AACE2201400_control.state == PLAY){
        marantz_power.sendCommand(ON) 
        marantz_input.sendCommand("CD") 
}
end
1 Like

you nailed it…

works now.

:+1:

Glad it’s working, do you understand why it now works?

honestly not sure but very eager to learn .

Rules will make a big difference so really really need to learn

The rule is actually simple the problem was the correct item name. Once you posted the log I was able to get the correct info for the rule to work. I originally thought the sonos item was a channel due to the length, :upside_down_face: but I guessed wrong. :grin: Going forward make sure your using the correct item names and types. :wink:

There are copious amounts of rule examples on the forum you just need to search a bit to find one that’s similar to what you need then modify it. BTW, I posted another rule example on your other topic for the pir sensor.

@BDE

I guess you have enabled “Simple Mode” in PaperUI --> Configuration --> System --> “Item Linking”.

Your sonos item looks like an autocreated item:

 sonos_CONNECT_RINCON_000E58AACE2201400_control

And your sonos items in .items file have probably linked wrong channels.