Hi everyone,
I am running OH 3.0.1 and I have some issues working with player items. (New rule, so I dont know if it would have been working on 2.5)
I have created two Player Items.
Player DenonPlayerViaHarmony is not linked to a channel and can be commanded by a sitemap
Player HarmonyPlayer is linked to my harmony binding and sends the commands to the device
I want to define a rule, where the command in DenonPlayerViaHarmony is only pushed to HarmonyPlayer if another Switch item is turned on (this exceptions isn’t implemented in the following code for debugging reasons - so the code should only push new commands for DenonPlayerViaHarmony to HarmonyPlayer.
Any attempts of doing so like
HarmonyPlayer.sendCommand(DenonPlayerViaHarmony.state)
does not work and causes the following error in log
==> /var/log/openhab/openhab.log <==
2021-03-25 07:53:06.871 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'harmony-1' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.sendCommand(org.openhab.core.items.Item,java.lang.String) on instance: null in harmony
In my next attempt, I want to identify the state by an if function and then, send the specific command
rule "Denon Steuerung Widergabe"
when Item DenonPlayerViaHarmony received command
then
if(DenonPlayerViaHarmony.state == PLAY)
{
HarmonyPlayer.sendCommand(PLAY)
}
if (DenonPlayerViaHarmony.state == PAUSE)
{
HarmonyPlayer.sendCommand(PAUSE)
}
if (DenonPlayerViaHarmony.state == NEXT)
{
HarmonyPlayer.sendCommand(NEXT)
}
if (DenonPlayerViaHarmony.state == PREVIOUS)
{
HarmonyPlayer.sendCommand(PREVIOUS)
}
if (DenonPlayerViaHarmony.state == FASTFORWARD)
{
HarmonyPlayer.sendCommand(FASTFORWARD)
}
if (DenonPlayerViaHarmony.state == REWIND)
{
HarmonyPlayer.sendCommand(REWIND)
}
end
This rule does work for PAUSE and PLAY state. But for no known reason, NEXT and PREVIOUS are triggering the rule but just sending the last command.
So if I set DenonPlayerViaHarmony to PLAY, HarmonyPlayer is set to PLAY accordingly
If I now set DenonPlayerViaHarmony to NEXT, Harmony Player is set to PLAY again. also with more attempts.
If I now set DenonPlayerViaHarmony to PAUSE, HarmonyPlayer is set to PAUSEaccordingly
If I now set DenonPlayerViaHarmony to NEXT, Harmony Player is set to PAUSE again.
==> /var/log/openhab/events.log <==
2021-03-25 08:20:31.497 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'DenonPlayerViaHarmony' received command NEXT
2021-03-25 08:20:31.512 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'HarmonyPlayer' received command PLAY
2021-03-25 08:20:31.516 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'HarmonyPlayer' predicted to become PLAY
Something has to be wrong in the if-function.
To solve it, I allready tried a conversion to String like this:
if(DenonPlayerViaHarmony.state.toString() == "PLAY")
{
HarmonyPlayer.sendCommand(PLAY)
}
if (DenonPlayerViaHarmony.state.toString() == "PAUSE")
{
HarmonyPlayer.sendCommand(PAUSE)
}
if (DenonPlayerViaHarmony.state.toString() == "NEXT")
{
HarmonyPlayer.sendCommand(NEXT)
}
Play and Pause do work again. Nest triggers again the last event.
Is this related to the differend types, stored in a Player Item? Like “PlayPauseType”, “RewindFastforwardType” etc? so by this, the .state only extracts the PlayPauseType? For what I know, there isnt any conversion like “.toPlayPauseType”.
What can I do to solve this?
Thanks in advance,
Tamo