Closed tavalin closed 5 years ago
Have you tried without the escaped quotes? IIRC, everything after the 'changed to' is taken in as a string, so I don't think you need to escape them. Or are you saying the actual value has escaped quotes in it? I could see that being a problem.
I've just tried it without quotes but still the same error, however this time it's due to the question mark in the string.
For reference, here is my rule as written in DSL:
rule "Audio Mode"
when
Item SONYReceiverSTRDN1080_Zone1_InputSource changed to "netService:audio?service=spotify"
then
SONYReceiverSTRDN1080_Master_SoundField.sendCommand("multiChStereo")
end
I'm seeing several issues when using StringItems. I never used them in my tests I did not fully test all the possibilities (spaces in new_state or old_state, invalid chars for the UID, etc.) and completely overlooked the implications. I'm wrapping up something else, but will look at this later tonight.
Describe the bug
I've run into an issue whilst trying to convert some of my DSL rules into jython rules.
I am using the following rule decorator which when parsed causes an invalid rule:
@when("Item SONYReceiverSTRDN1080_Zone1_InputSource changed to \"netService:audio?service=spotify\"")
The error given is:
(INVALID_RULE): Validation of rule 144040b7-9cc8-4db4-95b0-6ad7fbadd717 has failed! Invalid module uid: Item-SONYReceiverSTRDN1080_Zone1_InputSource-changed-to-"netService:audio?service=spotify". It is null or not fit to the pattern: [A-Za-z0-9_-]*
It appears that the library is trying to convert the when clause into a trigger uid. As my when clause contains escaped quotes (which is valid) when converted into a trigger uid it violates the given regex pattern ([A-Za-z0-9_-]*) governing valid trigger uids.
Have looked through the code briefly (and not being a python expert) I think the issue is on this line or the following lines:
https://github.com/openhab-scripters/openhab-helper-libraries/blob/master/Core/automation/lib/python/core/triggers.py#L236
To Reproduce Steps to reproduce the behavior:
Create the following jython rule and place in the personal directory:
Expected behavior The library creates a rule with a valid trigger uid.
Environment (please complete the following information):