• 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
regex mask for protocol options not working
#1
When testing the fixes I made for PR #400, I configured a generic_label device with an invalid option string value. The configuration type of that option is JSON_OPTIONAL and the vartype is JSON_STRING.

In the protocol I defined a mask for that option, but when I start pilight, no error message is given an pilight keeps running.

Having a quick look at devices.c I noticed that there are three places where the option mask is being checked, but one of them is only checking the mask for DEVICES_STATE and another one for DEVICES_ID.

The third one is in the function devices_valid_value(), which is actually checking the mask for DEVICES_VALUE and DEVICES_OPTIONAL, but that function seems to be called only from "pilight_control" and only works for strings.

So, imho the reason why the mask doesn't work is quite clear. But if necessary the behaviour can easily be reproduced by adding a regex mask to the color option of the generic_label protocol and then add a device with that protocol with a "color" string value that should not match with the regex.

I will now add a check for the validity of the option value to the protocol itself, but it would be nice if the option mask would work for DEVICES_VALUE and DEVICES_OPTIONAL too.
 
Reply
#2
The question is if we want to keep the mask feature altogether. I was planning to drop it when moving to lua protocols.
 
Reply
#3
OK, then the check I have put in the protocol will do the job.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Fixed] Fast sending codes in a row not working apartmedia 12 2,540 08-19-2019, 04:58 PM
Last Post: curlymo
  Protocol options defined as JSON_ARRAY getting lost Niek 6 1,814 01-01-2019, 11:03 AM
Last Post: curlymo
  [Solved] Rules switching state based on another device state not working apartmedia 6 2,281 09-27-2017, 01:41 PM
Last Post: apartmedia
  [Solved] dimmer protocol kaku_dimmer does not react on dimmervalue apartmedia 25 3,583 09-16-2017, 10:29 PM
Last Post: apartmedia
  [Solved] Webgui not working in IE Ulrich.Arnold 7 1,546 09-12-2017, 05:22 PM
Last Post: Ulrich.Arnold

Forum Jump:


Browsing: 1 Guest(s)