I am trying to modify the MyMQTT skill to allow for a regex expression - something like “Mycroft, turn the Living Room lights on.” Where “Living Room” would match a regex. I have tried numerous combinations and just can’t seem to get the regex to work - it never populates the variable.
Any help would be appreciated. My code can be found here: https://github.com/bkmar1192/mycroft-mymqtt
Sorry, i can’t give you any specific help. My experience with regex is that it can be a bit flakey (I have raised an issue about this). There are a couple of things that I can think of to try:
- There is a function (can’t remember what it is sorry) to return the unmatched part of the utterance. This may help to diagnose what is going on.
- The other is to just use keywords rather that regex. The downside is that you have to predefine the keywords into “.voc” files. That is what I use and it works quite well (https://github.com/aussieW/skill-mqtt-worldtime).
I think this is because of a bug with the use of ‘optionally.’ See https://github.com/MycroftAI/mycroft-core/issues/1241.
If you make it required, and it works, you might be able to work around the issue with two intents, one that requires the regex, and one that does not.
For those stumbling upon this - I never got the regex to work, required or otherwise. What I did to work around this was to use message.utterance_remainder() in my python code to get the unmatched portion of my utterance. Worked for my purposes.
I know this is an old post but I thought I would check and see if you ever got this working, i checked your code and it looks like you are using the regex again. I am having some issues and I thought it might be the same issue.