Need help with rule based on Dell Projector Power Toggle via Harmony Hub binding

  • Platform information: Raspberry Pi Nano

    • Hardware: Raspberry Pi Nano
    • OS: Rasbian image from openHABian
    • Java Runtime Environment:Zulu Embedded OpenJDK Java 8
    • openHAB version: 2
  • Issue of the topic: Need help with rule based on Dell Projector Power Toggle via Harmony Hub binding
    I want to setup a rule so when the Projector is turned on, the hue switch gets turned off. This way my lights won’t turn on in the middle of a movie.

  • Please post configurations (if applicable):

    • Items configuration related to the issue n/a

    • Sitemap configuration related to the issue n/a

    • Rules code related to the issue

//This rule does not work
rule "Test Turn off Living Room Lamp Sensor"

when
Item harmonyhub_device_HarmonyHub_38426233_buttonPress changed 

then
var url_switch = 'http://10.0.0.126/api/Ojw5c5hRrvlvQQmTMZS-W7W9nkLhNnSKKUVXdzfD/sensors/19'
sendHttpPutRequest(url_switch,"application/json",'{"config":{"on":false}}')

end

//this rule works 
rule "Test Turn off Living Room Lamp Sensor"
when
Item hue_0100_0017882c2e3c_23_brightness changed  // from 1 to 254
then
var url_switch = 'http://10.0.0.126/api/Ojw5c5hRrvlvQQmTMZS-W7W9nkLhNnSKKUVXdzfD/sensors/19'
sendHttpPutRequest(url_switch,"application/json",'{"config":{"on":false}}')
end

  • Services configuration related to the issue
    HarmonyHub Binding
    hue Binding

No errors in the log when I save the rule:

  • If logs where generated please post these here using code fences:
2018-01-19 13:21:32.296 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'HomeThearter.rules'

I don’t see an Item for the Projector but I do see in in Things. The channel is:
harmonyhub:device:HarmonyHub:38426233:buttonPress

Also I see all of the button options in the Paper UI Control. And the Power Toggle works there.

from another post I learned about the :8080/rest/channel-types URL & I see the “Power Toggle” here:

“UID”:“harmonyhub:device:HarmonyHub:38426233:buttonPress”,“advanced”:false},{“parameters”:[],“parameterGroups”:[],“description”:“Send a button press to device Amcrest DVR”,“label”:“Send Button Press”,“itemType”:“String”,“kind”:“STATE”,“stateDescription”:{“readOnly”:false,“options”:[{“value”:“PowerToggle”,“label”:“Power Toggle”},{“value”:“Number0”,“label”:“0”},{“value”:“Number1”,“label”:“1”},{“value”:“Number2”,“label”:“2”},{“value”:“Number3”,“label”:“3”},{“value”:“Number4”,“label”:“4”},{“value”:“Number5”,“label”:“5”},{“value”:“Number6”,“label”:“6”},{“value”:“Number7”,“label”:“7”},{“value”:“Number8”,“label”:“8”},{“value”:“Number9”,“label”:“9”},{“value”:“ChannelDown”,“label”:“Channel Down”},{“value”:“ChannelUp”,“label”:“Channel Up”},{“value”:“DirectionDown”,“label”:“Direction Down”},{“value”:“DirectionLeft”,“label”:“Direction Left”},{“value”:“DirectionRight”,“label”:“Direction Right”},{“value”:“DirectionUp”,“label”:“Direction Up”},{“value”:“Select”,“label”:“Select”},{“value”:“Stop”,“label”:“Stop”},{“value”:“Play”,“label”:“Play”},{“value”:“Rewind”,“label”:“Rewind”},{“value”:“Pause”,“label”:“Pause”},{“value”:“FastForward”,“label”:“Fast Forward”},{“value”:“Record”,“label”:“Record”},{“value”:“Menu”,“label”:“Menu”},{“value”:“Guide”,“label”:“Guide”},{“value”:“Exit”,“label”:“Exit”}]},“tags”:

With some help from the forum on another issue, I was able to figure out the solution to this. First, since the projector only has PowerToggle, I decided to use the DVD player instead since it has PowerOn and PowerOff events. So the rule looks like this:

rule "SonyBluRayPlayer_SendButtonPress Power"
when

Item  SonyBluRayPlayer_SendButtonPress received command

then
    if (receivedCommand == "PowerOn" )
	{
	logInfo("Harmony", "SonyBluRayPlayer_SendButtonPress is: " + receivedCommand)
var url_switch = 'http://10.0.0.126/api/(My Hue API Key)/sensors/19' 
sendHttpPutRequest(url_switch,"application/json",'{"config":{"on":false}}')

	} 
	else 
	{
     logInfo("Harmony", "SonyBluRayPlayer_SendButtonPress is: " + receivedCommand)
var url_switch = 'http://10.0.0.126/api/Ojw5c5hRrvlvQQmTMZS-W7W9nkLhNnSKKUVXdzfD/sensors/19'
sendHttpPutRequest(url_switch,"application/json",'{"config":{"on":true}}')

	}
end