• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Protocol options defined as JSON_ARRAY getting lost
I tried to add a protocol option that can have multiple values. To do this, I defined the option type as JSON_ARRAY.

Now, if I add a device to the config with that protocol and define some array values like shown  below, it works, but just once.

"myoption" : [ "value1", "value2" ],

When pilight starts, the array is available in the protocol and its values can be accessed, but when pilight is stopped, the setting has disappeared from the config.

If this intentional, I will have to use a different, less elegant solution like a csv string. But in that case imho the deamon should report ARRAY options as being invalid and should not silently remove them from the config.
True, can you help me reproduce it.

A fairly easy way to reproduce it, is to add a fake option to an existing protocol, let's say a generic_label:

options_add(&generic_label->options, "x", "arrayoption", OPTION_HAS_VALUE, DEVICES_SETTING, JSON_ARRAY, NULL, NULL);

And then create a config with just one generic_label device:

    "devices": {
        "testlabel": {
            "protocol": [ "generic_label" ],
            "id": [{
                "id": 1
            "label": "",
            "color": "black",
            "arrayoption": [ "val1", "val2" ]
    "rules": {
    "gui": {
    "settings": {
    "hardware": {
    "registry": {

If you run pilight-deamon  with this config once , you will see no errors. After stopping pilight, the "arrayoption" setting is no longer in the config.

Running a second time (with "arrayoption" gone) will not give any errors either, even though the setting is not optional. The order of the options in the config has no influence on this behaviour.

I hope this is helpfull.
I've added the requested error message. Implementing this feature would be too much work.
Happy New Year!

Ok, thanks. I will use a csv string instead then.
Imho the check contains a mistake and is incomplete.Unsure

First, the condition should be true if jsettings->key is NOT "id"
Second, not only "id" is an array, but also "protocol".

So I think the check should be:

PHP Code:
 if(jsettings->tag == JSON_ARRAY && strcmp(jsettings->key"id") != && strcmp(jsettings->key"protocol") != ) { 
Am I right?
Yes, seems i was too tired yesterday Smile

Possibly Related Threads...
Thread Author Replies Views Last Post
  regex mask for protocol options not working Niek 2 1,821 01-06-2019, 12:20 AM
Last Post: Niek
  [Solved] connection to main pilight daemon lost TopdRob 20 4,882 09-17-2017, 04:30 PM
Last Post: curlymo
  [Solved] dimmer protocol kaku_dimmer does not react on dimmervalue apartmedia 25 4,784 09-16-2017, 10:29 PM
Last Post: apartmedia

Forum Jump:

Browsing: 1 Guest(s)