예제 #1
0
 def load_plants_from_web_app(self):
     """Download known plants from the FarmBot Web App API."""
     if USE_FARMWARE_TOOLS:
         response = app.get_plants()
         app_plants = response if isinstance(response, list) else []
     else:
         response = self.api_get('points')
         points = response.json() if response.status_code == 200 else []
         app_plants = [p for p in points if p['pointer_type'] == 'Plant']
     plants = []
     for plant in app_plants:
         plants.append({
             'x': plant['x'],
             'y': plant['y'],
             'radius': plant['radius']
         })
     self.plants['known'] = plants
예제 #2
0
def run_tests(app_login):
    'Run app tests.'
    TIMESTAMP = str(int(time.time()))
    print(app.log('hi', get_info=app_login))
    print(app.request('GET', 'tools', get_info=app_login))
    print(app.get('sensors', get_info=app_login))
    TOOL = app.post('tools',
                    payload={'name': 'test_tool_' + TIMESTAMP},
                    get_info=app_login)
    print(TOOL)
    TOOL_ID = TOOL['id']
    print(
        app.put('tools',
                TOOL_ID,
                payload={'name': 'test_tool_edit_' + TIMESTAMP},
                get_info=app_login))
    print(app.delete('tools', TOOL_ID, get_info=app_login))
    print(app.search_points({'pointer_type': 'Plant'}, get_info=app_login))
    print(app.get_points(get_info=app_login))
    print(app.get_plants(get_info=app_login))
    print(app.get_toolslots(get_info=app_login))
    print(app.get_property('device', 'name', get_info=app_login))
    print(app.download_plants(get_info=app_login))
    PLANT = app.add_plant(x=100, y=100, get_info=app_login)
    print(PLANT)
    PLANT_ID = PLANT['id']
    print(app.delete('points', PLANT_ID, get_info=app_login))
    PLANT2 = app.add_plant(x=10,
                           y=20,
                           z=30,
                           radius=10,
                           openfarm_slug='mint',
                           name='test',
                           get_info=app_login)
    print(PLANT2)
    print(app.delete('points', PLANT2['id'], get_info=app_login))
    app.post('sequences', {'name': 'test', 'body': []}, get_info=app_login)
    app.post('sequences', {
        'name': u'test \u2713',
        'body': []
    },
             get_info=app_login)
    print(app.find_sequence_by_name(name=u'test \u2713', get_info=app_login))
    print(app.find_sequence_by_name(name='test', get_info=app_login))
    print()
예제 #3
0
#!/usr/bin/env python

'''
 ' A farmware for a custom tool for Farmbot
'''

import os, sys, json, Qualify
from random import randint
from farmware_tools import device, app, get_config_value
from Coordinate import Coordinate

PIN_LIGHTS = 7
PKG = 'Test Bed'

input_errors = []
integer = Qualify.integer(PKG, 'integer')

tools = app.get_toolslots()
device.log(json.dumps(tools))

tool = Qualify.get_tool(4469)
device.log(json.dumps(tool))

plants = app.get_plants()
device.log(json.dumps(plants))

device.write_pin(PIN_LIGHTS, 0, 0)
예제 #4
0
#!/usr/bin/env python
'''Fotos_highres_with_Names.
Take a photo using a USB or Raspberry Pi camera.
'''

import os
import time
import json
import requests
import numpy as np
import cv2
import sys
from farmware_tools import device, app

try:
    points =  app.get_plants()         #Get all points from webapp, would be smarter to get plants, will try that later
    position_x = int(round(device.get_current_position('x')))      #Actual X-Position
    position_y = int(round(device.get_current_position('y')))      #Actual Y-Position
    all_plants = []
except KeyError:
     log("Loading points/positions failed","error")


def farmware_api_url():

    major_version = int(os.getenv('FARMBOT_OS_VERSION', '0.0.0')[0])
    base_url = os.environ['FARMWARE_URL']
    return base_url + 'api/v1/' if major_version > 5 else base_url

def log(message, message_type):
    'Send a message to the log.'