pimatic / pimatic-plugin-template Goto Github PK
View Code? Open in Web Editor NEWA template for creating plugins
License: GNU General Public License v2.0
A template for creating plugins
License: GNU General Public License v2.0
Dear all,
I need help with the pimatic-ifttt plugin. node-ifttt
should be integrated so that the pimatic API does not have to be exposed to the internet. Please read https://github.com/baswenneker/pimatic-ifttt#todo-integrate-node-ifttt for more information.
It will take me to much time to integrate the ifttt server. So if someone is interested, please fork the code and create a pull request :)
https://github.com/baswenneker/pimatic-ifttt#todo-integrate-node-ifttt
How does inAnyOrder
work in the matcher and how do I use it correctly?
I'm currently trying to use the new matcher but having some problems. For every activ rule I get:
< error: Could not parse rule "if Push Test is pressed then push title:"push" message:"test" priority:0": Error executing a action handler: predicate is not defined, Could not find an action handler for: push title:"push" message:"test" priority:0
< debug: Error: Error executing a action handler: predicate 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 looks like this
matchCount = 0
title_content = null
message_content = null
priority_content = null
setTitle = (m, t) => title_content = t
setMessage = (m, mc) => message_content = mc
setPriority = (m, p) => priority_content = p
M(predicate, context)
.match('send ', optional: yes)
.match(['push ','pushover ','notification '])
.match('tile:', optional: yes)
.matchString(optional: yes, setTitle)
.match('message:')
.matchString(setMessage)
.match('priority:', optional: yes)
.matchNumber(optional: yes, setPriority)
.onEnd( => matchCount++)
if matchCount is 1
env.logger.debug "executeAction: we have matches, simulate:#{simulate}"
if simulate
return Q.fcall ->
env.logger.debug "executeAction: we simulate the action"
else
if !message_content
message_content = @config.title
if !title_content
title_content = @config.message
default_url_title = @configurl_title
default_url = @config.url
default_priority = @config.priority
default_sound = @config.sound
default_device = @config.device
return Q.fcall ->
msg =
message: message_content
title: title_content
sound: default_sound
priority: priority_content
env.logger.debug "executeAction: we send the message"
return Q.ninvoke(pushover_instance, "send", msg).then(->
Q.fcall env.logger.info "pusover message sent successfully")
else if matchCount > 1
context.addError(""""#{actionString.trim()}" is ambiguous.""")
Hi,
In the pimatic-plugin-template, the file is called "my-device-config-schema.coffee" but in the template script its expecting
@conf = convict require("./device-config-schema")
Should be renamed to avoid issues when using it as a template.
Thanks
Is there a method to define not only one FileBrowser, but to have a JSON setting for multiple 'roots', like "/media/data1" and "/media/data2".
I would not allow "/media" because that would give access to other sub-dirs as well.
(Alreday looked into the JSON definition and also the "coffee.pot" but could not find a way to extend it that way)
How is the documentation generated? It at least looks like it is generated.
Just trying to get the template file to run prior to renaming and making changes to it.
I have the config set as:
{
"plugin": "plugin-template"
}
and device
{
"id": "test1",
"name": "test1",
"class": "MySwitch"
}
and then getting error when I run it:
/home/pi/pimatic-dev/node_modules/pimatic/node_modules/q/q.js:126
throw e;
^
ReferenceError: conf is not defined
at new MySwitch (/home/pi/pimatic-dev/node_modules/pimatic-plugin-template/my-plugin.coffee:92:13)
at MyPlugin.createDevice (/home/pi/pimatic-dev/node_modules/pimatic-plugin-template/my-plugin.coffee:66:7)
at MyPlugin.createDevice (/home/pi/pimatic-dev/node_modules/pimatic-plugin-template/my-plugin.coffee:11:1)
at Framework.loadDevices (/home/pi/pimatic-dev/node_modules/pimatic/lib/framework.coffee:231:9)
at loadPlugins.then.then.then.then.then.then.context.waitFor (/home/pi/pimatic-dev/node_modules/pimatic/lib/framework.coffee:437:24)
at _fulfilled (/home/pi/pimatic-dev/node_modules/pimatic/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/home/pi/pimatic-dev/node_modules/pimatic/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/home/pi/pimatic-dev/node_modules/pimatic/node_modules/q/q.js:759:13)
at /home/pi/pimatic-dev/node_modules/pimatic/node_modules/q/q.js:573:44
at flush (/home/pi/pimatic-dev/node_modules/pimatic/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:902:3
I'm currently creating an plugin which provides an action handler, to test it I currently create a rule like "if it is 12:34 then myactionhandler myparameter" where 12:34 would be current time + one minute. Is there an easier way?
Hi, Have it up and running and able to turn devices on/off but cant figure out how to use the temperature device. Would like it to get the Pi temperature and also external temperature through yahoo or wunderground.
thanks
I've tried copying and pasting from other plugins but cant seem to retrieve the device details from the json file for my new plugin. Do I need to to pass config/deviceconfig in the create device and then assign it?
constructor: (deviceconfig) ->
@id = @config.id
@name = @config.name
@mycmd = @config.mycmd
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.