HTTP binding when state value != command value

Hi there,
I am struggeling with setting up a fibaro smart plug. I am using the FibaroGatway, that has a REST-API to read the state and change the state.
Unfortunately, the current state is defined as:
“value”.“true” ← means on
"value:“false” ← means off
so no problem, I use the onValue/offValue attributes
The part that I am struggling with is how to switch the state. it is done by the url /action/turnOn (and /action/turnOff)

channels:
  - id: Eingeschaltet
    channelTypeUID: http:switch
    label: Eingeschaltet
    description: ""
    configuration:
      onValue: "true"
      mode: READWRITE
      offValue: "false"
      stateTransformation: JSONPATH:$.properties.value
      commandExtension: /action/turnOn

I tried using MAP transformation in the Link as well as in the channel settings and I tried replacing the onValues with true /false and I tried to use the commandExtension with /action/turn%2$s I haven’t figured out how to do it.
I don’t want to write a rule for this… :confused:
Can you help?
thanks!

I am using:
version: 3.1.0.M3
buildString: Milestone Build
the http binding from SmartHomeJ
266 │ Active │ 80 │ 3.1.2.202104290318 │ SmartHome/J Add-ons :: Bundles :: HTTP Binding

Did you try using the MAP Transformation as commandTransformation?

onValue/offValue are “bidirectional” so of no use where you have different ins and outs.

You could make separate read-only and write-only channels, each with appropriate onValue/offValue, and link them both to the same Item.

Or, with no onValue/offValue at all, use both stateTransformation and commandTransformation. You could use the same MAP file for both lookup jobs.

I don’t think %2$s helps you, as it will substitute ON/OFF not On/Off

I didn‘t try, but I think that. MAP transformation of the outgoing value (command transformation)

true → On
false → Off

together with %2$s should do the trick. If it‘s not a bug, this should first use true as value for an ON command and then transform it to On and insert that as command in the outgoing request.

Thanks @J-N-K . It seems that I missed this constellation while trying all my possibilities last night.

channels:
  - id: Eingeschaltet
    channelTypeUID: http:switch
    label: Eingeschaltet
    description: ""
    configuration:
      onValue: "true"
      mode: READWRITE
      commandTransformation: MAP:trueON.map
      offValue: "false"
      stateTransformation: JSONPATH:$.properties.value
      commandExtension: /action/turn%2$s

using a transformatoin like this:

ON=true
OFF=false
true=On
false=Off

does the job.

2 Likes

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