Seite 1 von 1

Player Item, Next & Previous werden nicht gesetzt

Verfasst: 17. Nov 2019 19:25
von Suchtaa
Hallo,

ich habe eine Frage bezüglich des Player-Items.

Ich habe diese Rule, um mit Spotify zu interagieren. Das klappt für PLAY und PAUSE soweit auch gut.

Code: Alles auswählen

rule "Spotify Item zuweisung"
when
	Item spotify_player received update
then

	spotify_action.sendCommand(spotify_player.state.toString.toLowerCase())
	switch(spotify_player.state) {
		case PLAY: {
			spotify_action.sendCommand("play")
		}
		case PAUSE: {
			spotify_action.sendCommand("pause")
		}
		case NEXT: {
			spotify_action.sendCommand("next")
			logInfo("Spotify", "Updated NEXT: " + spotify_player.state.toString.toLowerCase())
		}
	}

	logInfo("Spotify", "Updated: " + spotify_player.state.toString.toLowerCase())
end
Mein Item in der Sitemap sieht so aus:

Code: Alles auswählen

Default item=spotify_player
Mein spotify_player Item sieht so aus:

Code: Alles auswählen

Player spotify_player
Wenn ich in der Sitemap dann Next oder Previous auswähle, wird der Wert nicht übernommen und auch die Rule wird nicht ausgeführt.
Wo muss ich denn noch Einstellen, dass diese Werte für das Item legitim sind?

Laut der Seite sollte das ganze ja eigentlich klappen (https://www.openhab.org/docs/configurat ... .html#type), oder überlese ich da etwas?

Auch wenn ich in der Karaf-Konsole das Item ändere

Code: Alles auswählen

smarthome:update spotify_player NEXT
kommt diese Fehlermeldung:
Error: State 'NEXT' is not valid for item 'spotify_player'
Valid data types are: ( PlayPauseType RewindFastforwardType UnDefType )

Re: Player Item, Next & Previous werden nicht gesetzt

Verfasst: 17. Nov 2019 23:30
von udo1toni
Du musst received command verwenden, da die UI Befehle sendet.

Code: Alles auswählen

rule "Spotify Item zuweisung"
when
    Item spotify_player received command
then
    spotify_action.sendCommand(spotify_player.state.toString.toLowerCase()) // diese Zeile muss vermutlich weg!
    switch(receivedCommand) {
        case PLAY: {
            spotify_action.sendCommand("play")
        }
        case PAUSE: {
            spotify_action.sendCommand("pause")
        }
        case NEXT: {
            spotify_action.sendCommand("next")
            logInfo("Spotify", "Updated NEXT: " + spotify_player.state.toString.toLowerCase())
        }
    }
    logInfo("Spotify", "Updated: " + spotify_player.state.toString.toLowerCase())
end

Re: Player Item, Next & Previous werden nicht gesetzt

Verfasst: 19. Nov 2019 19:01
von Suchtaa
Ahh, vielen dank! :)