RE: Samsung TV Binding (Beta)

Hi i wanna use this script but cant seem to get it working with your plugin

  // Check some condition, for example, if the TV is not already ON
    if (TV_Samsung_7_Series_55_Power.state != ON) {
        // Send the command to turn the TV ON
        TV_Samsung_7_Series_55_Power.sendCommand("ON")
    }

    // Send the command to change the input source to HDMI
    TV_Samsung_7_Series_55_Key_Code.sendCommand("KEY_HDMI")

    // Set the source name (assuming you have a valid item for this)
    TV_Samsung_7_Series_55_Source_Name.sendCommand("HDMI")

end

Please post code in code blocks. Your post is kind of half and half, which makes it difficult to read.

This looks like parts of a DSL rule, but you don’t say what isn’t working or what error messages you get in the log. All I can say is that you’re missing sendCommand on your first two commands.

openhab.log (8.6 KB)
Here is my log file

have also updated the code

You can usually just paste the relevant parts of the log into a message (also in code fences/blocks).

2024-01-29 21:29:43.148 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '4c45f95f99' failed:     // Check some condition, for example, if the TV is not already ON
    if Bedroom_TV_Power.state != ON) {
        // Send the command to turn the TV ON
        Bedroom_TV_Power.sendCommand("ON")
    }

    // Send the command to change the input source to HDMI
    Bedroom_TV_Key_Code.sendCommand("KEY_HDMI")

    // Set the source name (assuming you have a valid item for this)
    Bedroom_TV_Source_Name.sendCommand("HDMI")

end

Where did you get this code? The reason I couldn’t understand what you’re trying to do is that this is only the second half of a Rules DSL rule. This is what a complete rule looks like.

rule "name of rule"
when
    something happens
then
    do stuff
end

You’ve skipped the when and then portions.

If you haven’t used Rules DSL before, I don’t recommend starting now (since it’s deprecated). You should be able to do this in a UI rule without needing to code anything. If you really want to use Rules DSL, you need to learn the syntax.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.