コード例 #1
0
ファイル: float2fill.py プロジェクト: mbroome/hc
def run(args):
    state = controller.state.Controller(args)

    if args['value']:
        logger.info('trigger: %s: should disable water fill' % __name__)

        r = state.post({'nodeid': 6, 'childid': 5, 'state': 0})
コード例 #2
0
ファイル: state.py プロジェクト: mbroome/hc
   def POST(self, **args):
      state = controller.state.Controller(args)

      if args.has_key('body'):
         content = args['body']
      else:
         content = urllib.unquote_plus(cherrypy.request.body.read())
         if len(content) <= 0:
            for k in cherrypy.request.body_params:
               content = k
               break

      try:
         params = content.split('=')
         args[params[0]] = params[1]
      except:
         pass

      if args.has_key('nodeid') and args.has_key('childid'):
         device = '%s:%s' % (args['nodeid'], args['childid'])
      elif args.has_key('sensor'):
         device = args['sensor']
         parts = args['sensor'].split(':')
         args['nodeid'] = parts[0]
         args['childid'] = parts[1]

      args['device'] = device

      r = state.post(args)

      response = {'status': 'success', 'data': r, 'message': None}

      return(json.dumps(response))
コード例 #3
0
def run(args):
    state = controller.state.Controller(args)

    logger.info('Scene: %s: %s' % (__name__, description))

    # turn the pump on
    #r = state.post({'nodeid': 6, 'childid': 6, 'state': 1})
    #time.sleep(30)

    # turn on zone 6
    r = state.post({'nodeid': 6, 'childid': 4, 'state': 1})

    # wait a hour
    time.sleep(60 * 10)

    # turn off zone 6
    r = state.post({'nodeid': 6, 'childid': 4, 'state': 0})
コード例 #4
0
ファイル: allzones.py プロジェクト: mbroome/hc
def run(args):
    state = controller.state.Controller(args)

    logger.info('Scene ON: %s: %s' % (__name__, description))
    r = state.post({'nodeid': 6, 'childid': 5, 'state': 1})
    time.sleep(5)

    # zone 2
    logger.info('Scene: %s: zone 2' % __name__)
    r = state.post({'nodeid': 6, 'childid': 2, 'state': 1})
    time.sleep(60 * 10)
    r = state.post({'nodeid': 6, 'childid': 2, 'state': 0})

    time.sleep(30)

    # zone 3
    logger.info('Scene: %s: zone 3' % __name__)
    r = state.post({'nodeid': 6, 'childid': 3, 'state': 1})
    time.sleep(60 * 10)
    r = state.post({'nodeid': 6, 'childid': 3, 'state': 0})

    time.sleep(30)

    # zone 4
    logger.info('Scene: %s: zone 4' % __name__)
    r = state.post({'nodeid': 8, 'childid': 0, 'state': 1})
    time.sleep(60 * 10)
    r = state.post({'nodeid': 8, 'childid': 0, 'state': 0})

    time.sleep(30)

    # zone 5
    logger.info('Scene: %s: zone 5' % __name__)
    r = state.post({'nodeid': 8, 'childid': 1, 'state': 1})
    time.sleep(60 * 10)
    r = state.post({'nodeid': 8, 'childid': 1, 'state': 0})

    time.sleep(30)

    # zone 6
    logger.info('Scene: %s: zone 6' % __name__)
    r = state.post({'nodeid': 6, 'childid': 4, 'state': 1})
    time.sleep(60 * 10)
    r = state.post({'nodeid': 6, 'childid': 4, 'state': 0})

    logger.info('Scene OFF: %s: %s' % (__name__, description))
    r = state.post({'nodeid': 6, 'childid': 5, 'state': 0})
コード例 #5
0
                        action="store",
                        dest="state",
                        choices=['on', 'off'],
                        required=True,
                        help='State to set')

    args = parser.parse_args()
    return (args)


args = parseArgs()

state = controller.state.Controller(args)

# build up a request to look like a normal post
request = {}
device = args.sensor
parts = args.sensor.split(':')
request['nodeid'] = parts[0]
request['childid'] = parts[1]

request['device'] = device

if args.state == 'on':
    request['state'] = 1
else:
    request['state'] = 0

# make the request
r = state.post(request)