Thing configuration from rules

Yes, but this is most definitely not the case. I think this is a kind of special use case. We can discuss if it was an option to expose any configuration parameter as a channel by ticking a box in the UI or something. But this would cause a load of work to implement and may collide with the current code base of the z-wave binding.

Due to the complex nature of wanting to change thing configuration, a use will most likely use rules anyway, so still implementing a rule action for changing the configuration would be the easiest.

I will post at least a Procedure type function in the next week to come up with some examples.

I’m confused - what do you mean exactly? As far as I know it definitely is the case.

I agree this would be useful, and from the binding side, much easier :slight_smile: .

Sorry for the confusion. In my opinion, my special use-case of changing the dimming speed of a Fibaro Dimmer 2 is not interesting enough for the rest of the world to configure it as a channel for everyone.

I would probably disagree, and I’m pretty sure we already have this sort of thing configured in other devices.

Even better then. :slight_smile:

This is the followup about how I solved it using rules.

As mentioned above, changing a thing’s config using the openHAB /things endpoint works like a charm. So that’s what I’ll do and thoroughly test now. See my real life example:

rules

rule "Work: Slow down Dimmer when adapting level"
  when Item work_lights changed to 0
    or Item work_lights changed from 0
  then
  var Number new_value
    if(work_lights.state > 0){
      logWarn("work.dimmer.adapter", "Dimmer level adaption. Setting to slow steps.")
      new_value = 100
    }
    else
    {
      logWarn("work.dimmer.adapter", "Dimmer off. Setting to fast steps.")
      new_value = 2
    }
  val String json = '{"config_6_2": ' + new_value + '}'
  logWarn("work.dimmer.adapter", json)
  sendHttpPutRequest("http://openhab:8080/rest/things/zwave:device:bridge:node18/config", "application/json", json)
end

This works well with the Fibaro Dimmer 2 FGD212. I just hope they save the settings in a flash memory and not an EEPROM which can only handle a few hundret writes. I’ll report back here if this breaks prematurely.

I’ll also let you hear from any new findings and problems - if any. Until then, I am open to any questions regarding this and wish you guys a nice day!

Hi @gersilex!
Thanks for sharing this! I guess this only works for things that are managed via paperUI? For things I’ve added manually, it won’t work?

I believe all UIs in openHAB work through REST calls. Open Paper UI and monitor the traffic (developer tools-network, or Fiddler)

That’s clear. My assumption is that manually added things, change settings via REST API does not work. (Because they are “unmanaged”)

This is correct. Just like when editing a Thing using the PaperUI or any other UI, as you and @luckymallari pointed out correctly, openHAB will deny changing the unmanaged thing and answer with an HTTP 409 “Conflict” error:

{
  "error": {
    "message": "Cannot update Thing zwave:device:bridge:node18 as it is not editable.",
    "http-code": 409
  }
}

Hi Gersilex,

I can see in your val string json you send a variable, do you know if its possible to send the value/state of a string item?

Thanks

Hi Chris,

If we use a PUT to send configuration parameters, which works fine, how do we delete those parameters? Sending fields blank does not remove them, and it errors.

If I send 1111 to a code, how would I remove 1111 from the REST API

Thanks
Kris

It’s not possible to remove parameters - they are always available. You can change the value only.

The answer is you send an empty string :slight_smile:

Not really - this will set the parameter to an empty string - it won’t remove it.

Well in any case, sending an empty string removed the values. Which is exactly what I needed.
You’re so literal Chris :smiley:

All good, values/parameters, different but same to a mug like me.

Absolutely. You can assign anything to new_value, not just integers.

      new_value = outside_lux.state

should work just fine.

1 Like

You can also configure Things using jython. This may also work for unmanaged Things, but I haven’t tried it.

try:
    from org.openhab.core.thing import ThingUID
except:
    from org.eclipse.smarthome.core.thing import ThingUID

then from within a rule, for example:

z_thing = things.get(ThingUID("zwave:device:741b4f3b:node10"))
z_thing.getConfiguration().put("config_6_1", someValue)
1 Like

Unmanaged Things are not configurable. BTW, I have a core.things module nearly ready to commit.

Good to know.

Looking forward to it.