Comments (14)
predicate
propably should be actionString
?
from pimatic-plugin-template.
and be carefull matchString
has no option parameter, it just takes a callback at the moment, so
.matchString(optional: yes, setTitle)
will not work.
from pimatic-plugin-template.
ok you are right, copy&paste error...
thanks about the matchString, hmm will it work then if the "title:" is not supplied?
from pimatic-plugin-template.
M(actionString, context)
.match('send ', optional: yes)
.match(['push ','pushover ','notification '])
.match('tile:', optional: yes)
.matchString(setTitle)
.match('message:')
.matchString(setMessage)
.match('priority:', optional: yes)
.matchNumber(setPriority)
.onEnd( => matchCount++)
still doesn't seem to match
push title:"push" message:"test" priority:0
from pimatic-plugin-template.
thanks about the matchString, hmm will it work then if the "title:" is not supplied?
m = M(actionString, context)
.match('send ', optional: yes)
.match(['push ','pushover ','notification '])
next = m.match('tile:').matchString(setTitle)
unless next.hadNoMatches()
m = next
m.match...
from pimatic-plugin-template.
still doesn't seem to match
You don't match against the space between string end and message.
from pimatic-plugin-template.
with the "next" method you suggested I now get the following error:
< error: Could not parse rule "if Push Test is pressed then push title:"push" message:"test" priority:0": Error executing a action handler: inputs is not defined, Could not find an action handler for: push title:"push" message:"test" priority:0
< debug: Error: Error executing a action handler: inputs is not defined, Could not find an action handler for: push title:"push" message:"test" priority:0
< at RuleManager.addRuleByString.parseRuleString.then.rule (/Users/thex/dev-pimatic/node_modules/pimatic/lib/rules.coffee:340:5)
< at _fulfilled (/Users/thex/dev-pimatic/node_modules/pimatic/node_modules/q/q.js:798:54)
< at Promise.then.self.promiseDispatch.done (/Users/thex/dev-pimatic/node_modules/pimatic/node_modules/q/q.js:827:30)
< at Promise.promise.promiseDispatch (/Users/thex/dev-pimatic/node_modules/pimatic/node_modules/q/q.js:760:13)
< at messages (/Users/thex/dev-pimatic/node_modules/pimatic/node_modules/q/q.js:574:44)
< at flush (/Users/thex/dev-pimatic/node_modules/pimatic/node_modules/q/q.js:108:17)
< at process._tickCallback (node.js:415:13)
< at [object Object].Module.runMain [as _onTimeout] (module.js:499:11)
< at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
code now looks like this:
m = M(actionString, context)
.match('send ', optional: yes)
.match(['push ','pushover ','notification '])
next = m.match(' tile:').matchString(setTitle)
unless next.hadNoMatches()
m = next
next = m.match(' message:').matchString(setMessage)
unless next.hadNoMatches()
m = next
next = m.match(' priority:').matchNumber(setPriority)
unless next.hadNoMatches()
m = next
m.onEnd( => matchCount++)
from pimatic-plugin-template.
be welcome to development branch. Should be fixed now: pimatic/pimatic@21159dc
from pimatic-plugin-template.
.match(['push ','pushover ','notification ']) next = m.match(' tile:').matchString(setTitle)
Now you match against space twice. At the end of 'push '
and beginning of ' title'
from pimatic-plugin-template.
yes error is gone, sure it's development branch and might contain bug, this way we find them faster.
already removed the space after push but it still doesn't want to match. Couldn't we modify the regex to allow any number of spaces between the items to match?
from pimatic-plugin-template.
already removed the space after push but it still doesn't want to match. Couldn't we modify the regex to allow any number of spaces between the items to match?
We could, I will think about it. Try to debug how far it matches.
The matcher works like that: It tries to match its input (actionString
for the first one) against the given string or regexp and if it matches it returns a new matcher that has the remaining part as input and so you can call match on the returned matcher with the next part as input. If it doesn't match it returns an matcher with an empty input.
You can check if the current matcher did its job by dumping the inputs of the next one:
m = M('push message...', context).match('push ')
console.log(m.inputs) # should be ["message..."]
m = m.match('message')
console.log(m.inputs) # should be ["..."]
from pimatic-plugin-template.
found it... a tile is not a title ;)
from pimatic-plugin-template.
found it... a tile is not a title ;)
didn't see it, too :D
from pimatic-plugin-template.
ok great working now :) once you know how to use the matcher it makes defining the conditions much easier.
from pimatic-plugin-template.
Related Issues (10)
- How to debug actions? HOT 6
- Help with pimatic-ifttt
- How to generate documentation? HOT 1
- inAnyOrder for the matcher HOT 4
- Temperature device HOT 6
- Template file needs renaming HOT 1
- Template error - ReferenceError: conf is not defined HOT 2
- multiple filebrowser settings? HOT 2
- Retrieving device details from json HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pimatic-plugin-template.