Selection items with mappings

I have this item in the sitems:

Switch samsung_source “Source” (g_samsung) {mqtt="> [frodo:broadlink/tv/samsung/tv:command:tv:replay], >[frodo:broadlink/tv/samsung/hdmi1:command:hdmi1:replay], >[frodo:broadlink/tv/samsung/hdmi2:command:hdmi2:replay], >[frodo:broadlink/tv/samsung/hdmi3:command:hdmi3:replay]"}

I’ve tried these individual commands as switchs, ie mqtt to frodo topic broadlink/tv/samsung/hdmi1 when the mapping hdmi1 is received, and post “replay” to the topic.

The sitemap item is:

Selection item=samsung_source mappings=[hdmi1=“Apple TV”,hdmi2=PC,hdmi3=Chromecast,tv=TV]

But when I select something I see:

21:10:32.172 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/samsung_source' with an invalid status value 'TV'.
21:10:38.978 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/samsung_source' with an invalid status value 'tv'.
21:10:43.020 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at 'items/samsung_source' with an invalid status value 'hdmi1'.

What is the goal? To control a Samsung TV? (if yes: have you tried to use the Samsung TV 2.x Binding?)

By the way: What solution/device are you using as intermediate (MQTT based) to control the Samsung TV? (maybe this: Link1 and/or Link2 ?)

If you want to continue using MQTT, you can try the following:

Set up a dummy control item:

Number	TV_Input_Control	"TV Input Control"

Setup a String item to deliver the commands/payload to MQTT:

String	TV_Input_Command 	"TV Input Command"	{mqtt=">[frodo:broadlink/tv/samsung:command:*:default]"}

Setup a rule based on the dummy control item:

rule	"TV Input Control"
	when
		Item	TV_Input_Control	received command
	then
		switch(receivedCommand) {
			case 1 : TV_Input_Command.sendCommand("hdmi1")
			case 2 : TV_Input_Command.sendCommand("hdmi2")
			case 3 : TV_Input_Command.sendCommand("hdmi3")
			case 4 : TV_Input_Command.sendCommand("tv")
		}
end

In your sitemap:

Switch	item=TV_Input_Control	mappings=[1="Apple TV", 2="PC", 3="Chromecast", 4="TV"]

This example setup will publish a payload of hdmi1 to the topic broadlink/tv/samsung if you select “Apple TV” (option 1) in the sitemap. If you like it, adapt it to your exact setup :slight_smile:

Ps: If you need to use 4 different topics, you could setup your String item like you have done in the first post.

3 Likes

I’m using a broad link rm3. So the Samsung binding won’t work as this tv is a 2008, and pre “smart”

I’ve got individual switches for each or the source items, and wanted to try and get them into one item, preferably without writing a rule.

I thought I’d done similar with a source for a radio. That was mapped in the sitemap to cd and tuner