[SOLVED] DataValue not passed to value variable in plugins onChangeRequest function in Designer

Hi, I’m trying to use the sample plugin from https://thehomeremote.com/docs/plugins/.

I’ve imported the plugin code through “New Plugin->Import from Code” into a freshly created project. At first verything looked fine when I clicked on “SynchronizeDevices” and it created a “VirtualSwitch” device. So I created a button with a “Clicked” event which uses an Action “DataAction” which sets “{Binding VirtualSwitch.Switch}” to the value of 1.

Then I created a console.log function to log the value which is received in onChangeRequest. I can see that the onChangeRequest is called even with correct device + attribute but value is always “null”. Is this a bug or what am I doing wrong? I did not try this yet with a physical device but it happens in Designer “Run” mode.

I would have attached the plugin but as a new user I’m not allowed to do so. So what could be wrong?

BTW: I’m using 3.4.10 of the Designer (so latest version atm)

UPDATE: I found out that ‘1’ doesn’t work because device is type “Switch” which only Accepts “On” and “Off” as value. But how can I define a Device which accepts an arbitrary string? There’s no such capability from what I can tell.

Many Capabilities will restrict you to a specific set of values. A Switch, for example, will only accept On or Off as possible values. To add support for an arbitrary string you will need to use “Attributes” on the Device object. The Attributes property holds all custom attributes that don’t map to a Capability. In your case, you can add an Attribute called “SomeArbitraryString” (or whatever you wish to call it).

It’s generally recommended that before adding custom attributes that you 1st look through the Capabilities page in the docs. See if there’s a Capability already defined for the function you are programming. If nothing’s available, then add your custom attribute as described above.