Giter Site home page Giter Site logo

pimatic-plugin-template's Introduction

pimatic-plugin-template

See the development guide for details.

Some Tips:

Adding package dependencies

  • You can add other package dependencies by running npm install something --save. With the --save option npm will auto add the installed dependency in your package.json
  • You can always install all dependencies in the package.json with npm install

Commit your changes to git

  • Add all edited files with git add file. For example: git add package.json then commit you changes with git commit.
  • After that you can push you commited work to github: git push

pimatic-plugin-template's People

Contributors

flatsiedatsie avatar mwittig avatar sweetpi avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pimatic-plugin-template's Issues

How to debug actions?

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?

problems using the new matcher

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.""")

Template file needs renaming

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

Retrieving device details from json

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

Template error - ReferenceError: conf is not defined

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

multiple filebrowser settings?

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)

Temperature device

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.