BDE
(Bozidar)
April 13, 2020, 6:35am
1
Hi all
I have a rule where my Sonos turn on my reciever ,when Sonos start playing.
Althought rule work , i still need some minor changes.
It looks like this now.
rule "Sonos plays"
when
Item Sonos_stue_Controller changed
then
if(Sonos_stue_Controller.state == PLAY){
marantz_power.sendCommand(ON)
createTimer(now.plusSeconds(10)) [| marantz_input.sendCommand("CD") ]
createTimer(now.plusSeconds(10)) [|marantz_volume.sendCommand(35) ]
createTimer(now.plusSeconds(10)) [|Sonos_stue_Controller.sendCommand(PLAY) ]
}
end
My issue is IF Reciever is already ON and on another input when activating Sonos ,rule doesn’t work.
I am considering just turning reciever off ,before on ,but i am looking for better suggestions.
Any suggestions ?
Charley
(Charley)
April 13, 2020, 6:40am
2
Why don’t you check if the receiver is already ON
BDE
(Bozidar)
April 13, 2020, 7:20am
3
would that be something like this
rule "Sonos plays"
when
Item Sonos_stue_Controller changed
then
if(Sonos_stue_Controller.state == PLAY)
if(marantz_power.state == ON){
createTimer(now.plusSeconds(1)) [| marantz_input.sendCommand("CD") ]
createTimer(now.plusSeconds(1)) [|marantz_volume.sendCommand(35) ]
createTimer(now.plusSeconds(1)) [|Sonos_stue_Controller.sendCommand(PLAY) ]
}
else if(marantz_power.state == OFF){
createTimer(now.plusSeconds(10)) [| marantz_input.sendCommand("CD") ]
createTimer(now.plusSeconds(10)) [|marantz_volume.sendCommand(35) ]
createTimer(now.plusSeconds(10)) [|Sonos_stue_Controller.sendCommand(PLAY) ]
}
end
well no errors in log ,but seems to not work
Charley
(Charley)
April 13, 2020, 7:47am
4
Try to set you want to see in the log what it does
logInfo("Sonos switch","Marantz_power "+ marantz_power.state)
duiffie
(Marco)
April 13, 2020, 8:01am
5
Looks like you’re forgetting to switch on your marantz when it’s currently off.
try this:
rule "Sonos plays"
when
Item Sonos_stue_Controller changed
then
if(Sonos_stue_Controller.state == PLAY) {
if(marantz_power.state == ON) {
createTimer(now.plusSeconds(1)) [| marantz_input.sendCommand("CD") ]
createTimer(now.plusSeconds(1)) [|marantz_volume.sendCommand(35) ]
createTimer(now.plusSeconds(1)) [|Sonos_stue_Controller.sendCommand(PLAY) ]
} else if(marantz_power.state == OFF) {
marantz_power.sendCommand(ON)
createTimer(now.plusSeconds(10)) [| marantz_input.sendCommand("CD") ]
createTimer(now.plusSeconds(10)) [|marantz_volume.sendCommand(35) ]
createTimer(now.plusSeconds(10)) [|Sonos_stue_Controller.sendCommand(PLAY) ]
}
}
end
1 Like
BDE
(Bozidar)
April 13, 2020, 8:06am
6
yes i realized t hat before you wrote it ,but you also found my missing }
.
Works now thanks.
duiffie
(Marco)
April 13, 2020, 8:16am
7
Same rule, less complicated:
rule "Sonos plays"
when
Item Sonos_stue_Controller changed to PLAY
then
var timerSec = 1
if(marantz_power.state == OFF) {
marantz_power.sendCommand(ON)
timerSec = 10
}
createTimer(now.plusSeconds(timerSec)) [| marantz_input.sendCommand("CD") ]
createTimer(now.plusSeconds(timerSec)) [|marantz_volume.sendCommand(35) ]
createTimer(now.plusSeconds(timerSec)) [|Sonos_stue_Controller.sendCommand(PLAY) ]
end
BDE
(Bozidar)
April 13, 2020, 8:31am
8
help very appriciated .
I have another one i need to fine tune.
it when alarm is off it activates power outlets…(group)
Looks like this.
rule "Alarm deaktiveret"
when
Item Alarm_tilstand changed
then
if(Alarm_tilstand.state == ON){
gudtag.sendCommand(ON)
}
end
Issue is house automation is turning outlets off during the night ( not Openhab)
So i need to reactivate in the morning.
Any suggestions…
duiffie
(Marco)
April 13, 2020, 8:46am
9
use CRON or (maybe better): install and use the astro binding as rule trigger. so:
rule "Alarm deaktiveret"
when
Item Alarm_tilstand changed to ON or
Time cron "0 0 7 1/1 * ? *" // Every day at 07:00am
then
if (Alarm_tilstand.state == ON) gudtag.sendCommand(ON)
end
or (https://www.openhab.org/addons/bindings/astro/ )
rule "Alarm deaktiveret"
when
Item Alarm_tilstand changed to ON or
Channel 'astro:sun:home:rise#event' triggered START // Every day at sunrise
then
if (Alarm_tilstand.state == ON) gudtag.sendCommand(ON)
end
BDE
(Bozidar)
April 13, 2020, 8:52am
10
thx alot i will definately try it out…
why would you prefer astro …(just trying to learn)
I have astro installed…
duiffie
(Marco)
April 13, 2020, 8:56am
11
It all depends on your requirements. If the purpose is lighting, then using the astro binding is much more dynamic then cron. That’s because, for example, in summer you want lights to turn on at a different time then in winter. But if it’s all about wall outlets which just need to turn on at a certain static time throughout the whole year then cron might be sufficient.
system
(system)
Closed
May 25, 2020, 12:58am
13
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.