Example #1
0
 def __init__(self, gpio):
     Thread.__init__(self)
     # add plugin menu items:
     gv.plugin_menu.append(gvmenu_settings)
     gv.plugin_menu.append(gvmenu_button1)
     gv.plugin_menu.append(gvmenu_button2)
     # add urls:
     urls.extend(plugin_urls)
     # remaining plugin init:
     self.daemon = True
     self.name = 'garage'
     self.gpio = gpio
     self.status = ''
     self._sleep_time = 0
     self._door_state = {"1": "UNKNOWN", "2": "UNKNOWN"}
     self._event_time = 0  # events are buttons and door sensors
     self.settings = {}
     self.subject = "Garage"  # TODO add subject to settings file
     self.notify_qtr = False
     self.tp = 10  # seconds to pause thread loop
     self.start()
Example #2
0
import web
import gv  # Get access to SIP's settings
from urls import urls  # Get access to SIP's URLs
from sip import template_render
from webpages import ProtectedPage
from helpers import restart

installed = []

# Add new url(s).
if 'plugins.plugin_manager' not in urls:
    urls.extend([
        '/plugins', 'plugins.plugin_manager.plugins', '/upd-plugins',
        'plugins.plugin_manager.update_plugins', '/browse-plugins',
        'plugins.plugin_manager.browse_plugins', '/inst-plugins',
        'plugins.plugin_manager.install_plugins', '/pmr',
        'plugins.plugin_manager.restart_page'
    ])

    # Add this plugin to the home page plugins menu
    gv.plugin_menu.append(['Manage Plugins', '/plugins'])


def get_permissions():
    global installed
    try:
        permissions = []
        files = subprocess.check_output(['ls', 'plugins'])
        installed = [
            f for f in list(files.split('\n')) if re.match('[^_].+\.py$', f)
Example #3
0
# !/usr/bin/env python
from random import randint
import thread

import web, json, time, re
import gv # Get access to ospy's settings
import urllib, urllib2
from urls import urls # Get access to ospy's URLs
from gpio_pins import set_output
from ospy import template_render
from webpages import ProtectedPage

urls.extend(['/wa', 'plugins.weather_adj.settings', '/wj', 'plugins.weather_adj.settings_json', '/uwa', 'plugins.weather_adj.update']) # Add a new url to open the data entry page.
gv.plugin_menu.append(['Weather-based Rain Delay', '/wa']) # Add this plugin to the home page plugins menu

def weather_to_delay(run_loop=False):
    if run_loop:
        time.sleep(randint(3, 10)) # Sleep some time to prevent printing before startup information

    while True:
        data = get_weather_options()
        if data["auto_delay"] != "off":
            print("Checking rain status...")
            weather = get_weather_data() if data['weather_provider'] == "yahoo" else get_wunderground_weather_data()
            delay = code_to_delay(weather["code"])
            if delay > 0:
                print("Rain detected: " + weather["text"] + ". Adding delay of " + str(delay))
                gv.sd['rd'] = float(delay)
                gv.sd['rdst'] = gv.now + gv.sd['rd'] * 3600 + 1 # +1 adds a smidge just so after a round trip the display hasn't already counted down by a minute.
                stop_onrain()
            elif delay == 0:
Example #4
0
import gv  # Get access to ospi's settings, gv = global variables
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage

gv.use_gpio_pins = False  # Signal OSPi to not use GPIO pins

# Load the Raspberry Pi GPIO (General Purpose Input Output) library
try:
    import RPi.GPIO as GPIO
except IOError:
    pass

# Add a new url to open the data entry page.
urls.extend(['/rb', 'plugins.relay_board.settings',
	'/rbj', 'plugins.relay_board.settings_json',
	'/rbu', 'plugins.relay_board.update']) 

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Relay Board', '/rb'])

params = {}

# Read in the parameters for this plugin from it's JSON file
def load_params():
    global params
    try:
        with open('./data/relay_board.json', 'r') as f:  # Read the settings from file
            params = json.load(f)
    except IOError: #  If file does not exist create file with defaults.
        params = {
Example #5
0
import string
import calendar

from helpers import get_cpu_temp, check_login, password_hash
import web
import gv  # Gain access to sip's settings
from urls import urls  # Gain access to sip's URL list
from webpages import ProtectedPage, WebPage

##############
## New URLs ##

urls.extend([
    '/jo', 'plugins.mobile_app.options', '/jc',
    'plugins.mobile_app.cur_settings', '/js',
    'plugins.mobile_app.station_state', '/jp',
    'plugins.mobile_app.program_info', '/jn',
    'plugins.mobile_app.station_info', '/jl', 'plugins.mobile_app.get_logs',
    '/sp', 'plugins.mobile_app.set_password'
])

#######################
## Class definitions ##


class options(WebPage):  # /jo
    """Returns device options as json."""
    def GET(self):
        web.header('Access-Control-Allow-Origin', '*')
        web.header('Content-Type', 'application/json')
        web.header('Cache-Control', 'no-cache')
        if check_login():
Example #6
0
# !/usr/bin/env python
# -*- coding: utf-8 -*-

import web  # web.py framework
import gv  # Get access to SIP's settings
from urls import urls  # Get access to SIP's URLs
from sip import template_render  #  Needed for working with web.py templates
from webpages import ProtectedPage  # Needed for security
import json  # for working with data file

# Add new URLs to access classes in this plugin.
urls.extend([
    '/proto-sp', 'plugins.proto.settings',
    '/proto-save', 'plugins.proto.save_settings'

    ])

# Add this plugin to the PLUGINS menu ['Menu Name', 'URL'], (Optional)
gv.plugin_menu.append([_('Proto Plugin'), '/proto-sp'])

def empty_function():  # Only a place holder
    """
    Functions defined here can be called by classes
    or run when the plugin is loaded. See comment at end.
    """
    pass


class settings(ProtectedPage):
    """
    Load an html page for entering plugin settings.
Example #7
0
""" SIP plugin uses mqtt plugin to broadcast station status every time it changes.
"""
__author__ = "Daniel Casner <*****@*****.**>"

import web  # web.py framework
import gv  # Get access to SIP's settings
from urls import urls  # Get access to SIP's URLs
from sip import template_render  #  Needed for working with web.py templates
from webpages import ProtectedPage  # Needed for security
from blinker import signal # To receive station notifications
import json  # for working with data file
from plugins import mqtt

# Add new URLs to access classes in this plugin.
urls.extend([
    '/zone2mqtt-sp', 'plugins.mqtt_zones.settings',
    '/zone2mqtt-save', 'plugins.mqtt_zones.save_settings'
    ])
gv.plugin_menu.append(['MQTT zone broadcaster', '/zone2mqtt-sp'])

class settings(ProtectedPage):
    """Load an html page for entering plugin settings.
    """
    def GET(self):
        settings = mqtt.get_settings()
        zone_topic = settings.get('zone_topic', gv.sd[u'name'] + '/zones')
        return template_render.mqtt_zones(zone_topic, "")  # open settings page

class save_settings(ProtectedPage):
    """Save user input to json file.
    Will create or update file when SUBMIT button is clicked
    CheckBoxes only appear in qdict if they are checked.
Example #8
0
import web
import gv  # Get access to sip's settings
from urls import urls  # Get access to sip's URLs
from sip import template_render
from webpages import ProtectedPage
from helpers import uptime, get_ip, get_cpu_temp, get_rpi_revision, stop_stations, set_output
from blinker import signal
import pylcd2
import Adafruit_GPIO.GPIO as GPIO
import OneButton

# Add a new url to open the data entry page.
urls.extend([
    '/lcd-button', 'plugins.lcd_button.settings', '/lcd-buttonj',
    'plugins.lcd_button.settings_json', '/ulcd-but',
    'plugins.lcd_button.update'
])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['LCD-Button Settings', '/lcd-button'])

################################################################################
# Main function loop:                                                          #
################################################################################

TICK_DELAY = 0.05


class LCDSender(Thread):
    def __init__(self, queue):
Example #9
0
load_params()
image_path = os.path.join('.', 'static', 'images')

try:
    os.makedirs(image_path)
except OSError as exc:  # Python >2.5
    if exc.errno == errno.EEXIST and os.path.isdir(image_path):
        pass
    else:
        raise

try:
    # Add a new url to open the data entry page if camera working
    if 'plugins.camera' not in urls:
        urls.extend(['/ca', 'plugins.camera.view_camera',
            '/cau', 'plugins.camera.change_camera',
            '/cap', 'plugins.camera.pic', 
            '/captz', 'plugins.camera.ptz']) 

        # Add this plugin to the home page plugins menu
        gv.plugin_menu.append(['Camera', '/ca'])

    take_picture('camera.jpg')

except:
    pass

zones = signal('zone_change')
zones.connect(on_zone_change)

################################################################################
# Web pages:                                                                   #
Example #10
0
from blinker import signal
import web, json, time
import gv  # Get access to ospi's settings, gv = global variables
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage
import picamera
from time import sleep
import os
import errno

# Add a new url to open the data entry page.
urls.extend(['/ca', 'plugins.camera.settings',
	'/caj', 'plugins.camera.settings_json',
	'/cau', 'plugins.camera.update',
        '/cap', 'plugins.camera.pic', 
        '/captz', 'plugins.camera.ptz']) 

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Camera', '/ca'])

params = {}

# Read in the parameters for this plugin from it's JSON file
def load_params():
    global params
    try:
        with open('./data/camera.json', 'r') as f:  # Read the settings from file
            params = json.load(f)
    except IOError: #  If file does not exist create file with defaults.
Example #11
0
from time import sleep
import subprocess

# local module imports
from blinker import signal
import gv  # Get access to SIP's settings
from sip import template_render  #  Needed for working with web.py templates
from urls import urls  # Get access to SIP's URLs
import web  # web.py framework
from webpages import ProtectedPage  # Needed for security

# Add new URLs to access classes in this plugin.
# fmt: off
urls.extend([
    u"/shutdown",
    u"plugins.shutdown_button.settings",
    u"/endSip",
    u"plugins.shutdown_button.stop",
])
# fmt: on

# Add this plugin to the PLUGINS menu ["Menu Name", "URL"], (Optional)
gv.plugin_menu.append([_(u"Shutdown button"), u"/shutdown"])

# def end_sip():
#     """
#     Functions defined here can be called by classes
#     or run when the plugin is loaded. See comment at end.
#     """
#     subprocess.call(poweroff)

Example #12
0
import web
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage, WebPage, load_and_save_remote, message_base, validate_remote, get_ip_to_base
from helpers import jsave, get_ip, read_log, reboot, get_remote_sensor_boards, update_upnp, update_hostname, update_tza, mkdir_p
from system_update import checker as updatechecker
import subprocess

disable_substations = False
# Add a new url to open the data entry page.  DO THIS AFTER possible error exit in initialize_fm_pins()
if 'plugins.substations' not in urls:
    if gv.sd['master']:
        urls.extend(['/suslv',  'plugins.substations.view_substations',
                     '/suslj',  'plugins.substations.join_master',
                     '/susde',  'plugins.substations.delete_substation',
                     '/suset',  'plugins.substations.set_substation',
                     '/susle',  'plugins.substations.execute_substation'])
    if gv.sd['slave']:
        urls.extend(['/susldr',  'plugins.substations.slave_data_request'])
        urls.extend(['/suiface',  'plugins.substations.slave_iface'])

    urls.extend(['/surrsd',  'plugins.substations.receive_remote_sensor_data'])
    urls.extend(['/surzd',  'plugins.substations.remote_zone_data'])

    if not gv.sd['slave'] and not gv.sd['master']:
        disable_substations = True

    # Add this plugin to the home page plugins menu
    #gv.plugin_menu.append(['Substations', '/sua'])
import json
import time

import web
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage


# Add a new url to open the data entry page.
urls.extend(
    [
        "/cama",
        "plugins.california_monthly.monthly_percent",
        "/cauma",
        "plugins.california_monthly.update_percents",
        "/cacalcma",
        "plugins.california_monthly.calc_percents",
    ]
)

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(["California Monthly", "/cama"])


def set_wl(run_loop=False):
    """Adjust irrigation time by percent based on historical California climate data."""
    if run_loop:
        time.sleep(2)  # Sleep some time to prevent printing before startup information

    last_month = 0
Example #14
0
# !/usr/bin/env python
from random import randint
import thread
import json
import time

import web
import gv  # Get access to ospy's settings
from urls import urls  # Get access to ospy's URLs
from ospy import template_render
from webpages import ProtectedPage


# Add a new url to open the data entry page.
urls.extend(['/ma', 'plugins.monthly_adj.monthly_percent', '/uma', 'plugins.monthly_adj.update_percents'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Monthly Adjust', '/ma'])


def set_wl(run_loop=False):
    """Adjust irrigation time by percent based on historical climate data."""
    if run_loop:
        time.sleep(randint(3, 10))  # Sleep some time to prevent printing before startup information

    last_month = 0
    while True:
        with open('./data/levels.json', 'r') as f:  # Read the monthly percentages from file
            levels = json.load(f)
        month = time.localtime().tm_mon  # Get current month.
        if month != last_month:
Example #15
0
#!/usr/bin/env python
'''Pulses a selected circuit with a 2.5 Hz signal for 30 sec
to discover the location of a valve'''
import web
from time import sleep
import gv # Get access to ospi's settings
from urls import urls # Get access to ospi's URLs
from ospi import template_render  #  Needed for working with web.py templates
from helpers import stop_stations, jsave
from webpages import ProtectedPage  # Needed for security
from gpio_pins import set_output


urls.extend([
             '/puls', 'plugins.pulse_cct.pulse',
             '/puls-run', 'plugins.pulse_cct.p_run',
             '/puls-stop', 'plugins.pulse_cct.p_stop',
             '/puls-sen', 'plugins.pulse_cct.p_save_enabled'
             ]) 
gv.plugin_menu.append(['Pulse Circuit', '/puls']) # Add this plugin to the home page plugins menu

stop = True

def chatter(cct):
    stop_stations()
    t = 0
    for cnt in range(150):      
        t = 1 - t #  toggle cct
        gv.srvals[cct] = t      
        set_output()
        sleep(0.2)
        if stop:
Example #16
0
    daysWatched = d
    metrics=m
    return
    
try:
    from apscheduler.scheduler import Scheduler #This is a non-standard module. Needs to be installed in order for this feature to work.
except ImportError:
    pass

try:
    sched = Scheduler()
    sched.start() # Start the scheduler
except NameError:
    pass    

urls.extend(['/auto', 'plugins.auto_program.auto_program', '/uap', 'plugins.auto_program.update_auto_program', '/rap', 'plugins.auto_program.start_auto_program']) # Add a new url to open the data entry page
gv.plugin_menu.append(['Auto-Program', '/auto']) # Add this plugin to the home page plugins menu
    
def runAutoProgram():
    global daysWatched
    global metrics
    days=[0,0]
    zone_history=[]

    wx_settings.checkRain()
    if not gv.sd['en']: return # check operation status
    if gv.sd['rd'] or (gv.sd['urs'] and gv.sd['rs']): # If rain delay or rain detected by sensor then exit
        return

    # this routine will create a new program for today based on historical rainfall total and last 7 day watering
    try:
Example #17
0
# !/usr/bin/env python

import web  # web.py framework
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs
from ospi import template_render  #  Needed for working with web.py templates
from webpages import ProtectedPage  # Needed for security
import json  # for working with data file

# Add new URLs to access classes in this plugin.
urls.extend([
    '/proto-sp', 'plugins.proto.settings', '/proto-save',
    'plugins.proto.save_settings'
])

# Add this plugin to the PLUGINS menu ['Menu Name', 'URL'], (Optional)
gv.plugin_menu.append(['Proto Plugin', '/proto-sp'])


def empty_function():  # Only a place holder
    """
    Functions defined here can be called by classes
    or run when the plugin is loaded. See comment at end.
    """
    pass


class settings(ProtectedPage):
    """
    Load an html page for entering plugin settings.
    """
Example #18
0
        import RPi.GPIO as GPIO

        pi = 0
except IOError:
    pass

# BUZZER VARIABLES
# Board pin where the buzzer is located (set to -1 to disable)
BUZZER_PIN = 32
# True if buzzer sounds when pin is HIGH; False if buzzer sounds when pin is LOW
BUZZER_ACTIVE_HIGH = True

# Add new URLs to access classes in this plugin.
urls.extend(
    [
        u"/buzzer-sp", u"plugins.buzzer.settings",
        u"/buzzer-save", u"plugins.buzzer.save_settings",
    ]
)

# Add this plugin to the PLUGINS menu ['Menu Name', 'URL'], (Optional)
gv.plugin_menu.append([u"Buzzer Plugin", u"/buzzer-sp"])

# This class handles the buzzer hardware
class Buzzer(Thread):
    def __init__(self, pin, active_high):
        Thread.__init__(self)
        # set to true when buzzer pin is initialized
        self.pin_initialized = False
        # Board pin where buzzer is located (-1 to disable)
        self.pin = pin
        # True if buzzer sounds when pin is HIGH; False if buzzer sounds when pin is LOW
Example #19
0
import time
import sys
import traceback

import web
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage
from helpers import stop_stations

# Add a new url to open the data entry page.
urls.extend([
    "/pressa",
    "plugins.pressure_adj.settings",
    "/pressj",
    "plugins.pressure_adj.settings_json",
    "/upressa",
    "plugins.pressure_adj.update",
])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(["Pressure Monitor Settings", "/pressa"])

################################################################################
# GPIO input pullup:                                                           #
################################################################################

from gpio_pins import GPIO as GPIO

try:
    if gv.platform == "pi":  # If this will run on Raspberry Pi:
import thread
import json
import time

import web
import gv  # Get access to sip's settings
from urls import urls  # Get access to sip's URLs
from sip import template_render
from webpages import ProtectedPage


# Add a new url to open the data entry page.
urls.extend([
    '/cama', 'plugins.california_monthly.monthly_percent',
    '/cauma', 'plugins.california_monthly.update_percents',
    '/cacalcma', 'plugins.california_monthly.calc_percents'
])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['California Monthly', '/cama'])


def set_wl(run_loop=False):
    """Adjust irrigation time by percent based on historical California climate data."""
    if run_loop:
        time.sleep(2)  # Sleep some time to prevent printing before startup information

    last_month = 0
    while True:
        try:
Example #21
0
import sys
sys.path.insert(0, './plugins')
import web, json, time, io, re, urllib2, datetime
import gv # Get access to ospi's settings
from urls import urls # Get access to ospi's URLs
import auto_program 

try:
    from apscheduler.scheduler import Scheduler #This is a non-standard module. Needs to be installed in order for this feature to work.
except ImportError:
    pass

urls.extend(['/wx', 'plugins.wx_settings.wx_settings', '/uwx', 'plugins.wx_settings.update_wx_settings']) # Add a new url to open the data entry page
try:
    sched = Scheduler()
    sched.start() # Start the scheduler
except NameError:
    pass    

#if it has rained today, then set rain to true
def checkRain():
    rtoday=0
    with io.open(r'./data/wx_settings.json', 'r') as data_file: 
        data = json.load(data_file)
    data_file.close()  
    rtoday=getWUTodayRain(data['wx']['apikey'],data['wx']['pws'])
    # print "rain today=", rtoday
    if rtoday and not gv.sd['urs']:
        gv.sd['rs'] = 1
    else:
        gv.sd['rs'] = 0  
import time
import subprocess
import sys
import traceback

import web
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLsimport errno
from ospi import template_render
from webpages import ProtectedPage
from helpers import restart


# Add a new url to open the data entry page.
urls.extend(['/UPs', 'plugins.system_update.status_page',
             '/UPsr', 'plugins.system_update.refresh_page',
             '/UPu', 'plugins.system_update.update_page',
             '/UPr', 'plugins.system_update.restart_page'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['System update', '/UPs'])


class StatusChecker(Thread):
    def __init__(self):
        Thread.__init__(self)
        self.daemon = True
        self.start()
        self.started = Event()
        self._done = Condition()

        self.status = {
Example #23
0
from urls import urls  # Get access to ospi's URLs
from ospy import template_render
from webpages import ProtectedPage
from helpers import get_rpi_revision

# I2C bus Rev Raspi RPI=1 rev1 RPI=0 rev0 
try:
    import smbus  # for PCF 8591
    ADC = smbus.SMBus(1 if get_rpi_revision() >= 2 else 0)
except ImportError:
    ADC = None

# Add a new url to open the data entry page.
urls.extend(['/pcf', 'plugins.pcf_8591_adj.settings',
             '/pcfj', 'plugins.pcf_8591_adj.settings_json',
             '/pcfa', 'plugins.pcf_8591_adj.update',
             '/pcfl', 'plugins.pcf_8591_adj.pcf_log',
             '/pcfr', 'plugins.pcf_8591_adj.delete_log'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['PCF8591 voltage and temperature settings ', '/pcf'])

################################################################################
# Main function loop:                                                          #
################################################################################


class PCFSender(Thread):
    def __init__(self):
        Thread.__init__(self)
        self.daemon = True
Example #24
0
"""
__author__ = "Daniel Casner <*****@*****.**>"

import web  # web.py framework
import gv  # Get access to SIP's settings
from urls import urls  # Get access to SIP's URLs
from sip import template_render  #  Needed for working with web.py templates
from webpages import ProtectedPage  # Needed for security
from blinker import signal # To receive station notifications
from helpers import schedule_stations
import json  # for working with data file
from plugins import mqtt

# Add new URLs to access classes in this plugin.
urls.extend([
    '/mr1-sp', 'plugins.mqtt_schedule.settings',
    '/mr1-save', 'plugins.mqtt_schedule.save_settings'
    ])
gv.plugin_menu.append(['MQTT scheduler', '/mr1-sp'])

class settings(ProtectedPage):
    """Load an html page for entering plugin settings.
    """
    def GET(self):
        settings = mqtt.get_settings()
        zone_topic = settings.get('schedule_topic', gv.sd[u'name'] + '/schedule')
        return template_render.mqtt_schedule(zone_topic, "")  # open settings page

class save_settings(ProtectedPage):
    """Save user input to json file.
    Will create or update file when SUBMIT button is clicked
    CheckBoxes only appear in qdict if they are checked.
Example #25
0
DATA_FILE = u"./data/mqtt.json"

_client = None
_settings = {
    u"broker_host": u"localhost",
    u"broker_port": 1883,
    u"broker_username": u"user",
    u"broker_password": u"pass",
    u"publish_up_down": u"",
}
_subscriptions = {}

# Add new URLs to access classes in this plugin.
# fmt: off
urls.extend([
    u"/mqtt-sp", u"plugins.mqtt.settings", u"/mqtt-save",
    u"plugins.mqtt.save_settings"
])
# fmt: on

gv.plugin_menu.append([u"MQTT", u"/mqtt-sp"])

NO_MQTT_ERROR = u"MQTT plugin requires paho mqtt python library. On the command line run `pip install paho-mqtt` and restart SIP to get it."


class settings(ProtectedPage):
    """Load an html page for entering plugin settings.
    """
    def GET(self):
        settings = get_settings()
        return template_render.mqtt(
            settings, gv.sd[u"name"],
Example #26
0
# local module imports
from blinker import signal
import gv  # Get access to SIP's settings
from helpers import timestr
from sip import template_render
from urls import urls  # Get access to SIP's URLs
import web
from webpages import ProtectedPage


# Add a new url to open the data entry page.
# fmt: off
urls.extend(
    [
        "/emls", "plugins.sip_email.settings",
        "/emljson", "plugins.sip_email.settings_json",
        "/emlu", "plugins.sip_email.update",
        "/emltst", "plugins.sip_email.send_test_email",
    ]
)
# fmt: on

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(["Email settings", "/emls"])

sent = 0
send_lst = []
status = ""
stn_sum = 0
prog_name = ""
p_num = 0
Example #27
0
from random import randint
import json
import time
import sys
import traceback

import web
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage
from helpers import uptime, get_ip, get_cpu_temp, get_rpi_revision

# Add a new url to open the data entry page.
urls.extend(['/lcd', 'plugins.lcd_adj.settings',
             '/lcdj', 'plugins.lcd_adj.settings_json',
             '/lcda', 'plugins.lcd_adj.update'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['LCD Settings', '/lcd'])

################################################################################
# Main function loop:                                                          #
################################################################################


class LCDSender(Thread):
    def __init__(self):
        Thread.__init__(self)
        self.daemon = True
        self.start()
Example #28
0
import time

import web
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage
from helpers import restart

installed = []

# Add new url(s).
urls.extend([
            '/plugins', 'plugins.plugin_manager.plugins',
            '/upd-plugins', 'plugins.plugin_manager.update_plugins',
            '/browse-plugins', 'plugins.plugin_manager.browse_plugins',
            '/inst-plugins', 'plugins.plugin_manager.install_plugins',
            '/pmr', 'plugins.plugin_manager.restart_page'
             ])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Manage Plugins', '/plugins'])

def get_permissions():
    global installed
    try:
        permissions = []
        files = subprocess.check_output(['ls', 'plugins'])
        installed = [f for f in list(files.split('\n')) if re.match('[^_].+\.py$', f)]
        pm = installed.index('plugin_manager.py')
        del installed[pm] #  Remove this plugin from list
Example #29
0
from webpages import ProtectedPage
from threading import Thread

# gv.pd Reference
###########################
# 0: On or Off
# 1: Weekly (127) or interval
# 2: Something to do with interval (0 if weekly)
# 3: Start time in minutes from 00:00 hours (300 == 5:00 AM)
# 4: End time in minutes from 00:00 hours (720 == 12:00 PM)
# 5: Reccuring length in mins
# 6: Duration in seconds
# 7: Bitwise value of the stations the program applies to

# Add a new url to open the data entry page.
urls.extend(['/ss', 'plugins.sunrise_sunset.sunrise_sunset', '/uss', 'plugins.sunrise_sunset.update'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Sunrise Sunset', '/ss'])

class SunriseSunset(Thread):
    def __init__(self):
        Thread.__init__(self)
        self.daemon = True
        self.start()
        self.status = ''
        self._sleep_time = 0

    def add_status(self, msg):
        if self.status:
            self.status += '\n' + msg
Example #30
0
#!/usr/bin/env python

from blinker import signal
import subprocess
import web, json, time
import gv  # Get access to sip's settings, gv = global variables
from urls import urls  # Get access to sip's URLs
from sip import template_render
from webpages import ProtectedPage

gv.use_gpio_pins = False  # Signal sip to not use GPIO pins

# Add a new url to open the data entry page.
urls.extend([
    '/rfc', 'plugins.rf_control.settings', '/rfcj',
    'plugins.rf_control.settings_json', '/rfcu', 'plugins.rf_control.update'
])

# Add this plugin to the plugins menu
gv.plugin_menu.append(['RF Control', '/rfc'])

commands = {}
prior = [0] * len(gv.srvals)


# Read in the parameters for this plugin from it's JSON file
def load_params():
    global commands
    try:
        with open('./data/rf_control.json',
                  'r') as f:  # Read the settings from file
Example #31
0
#!/usr/bin/env python

import web, json, time
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs

try:
    from apscheduler.scheduler import (
        Scheduler,
    )  # This is a non-standard module. Needs to be installed in order for this feature to work.
except ImportError:
    print "The Python module apscheduler could not be found."
    pass

urls.extend(
    ["/ma", "plugins.monthly_adj.monthly_percent", "/uma", "plugins.monthly_adj.update_percents"]
)  # Add a new url to open the data entry page.

gv.plugin_menu.append(["Monthly Adjust", "/ma"])  # Add this plugin to the home page plugins menu

try:
    sched = Scheduler()
    sched.start()  # Start the scheduler
except NameError:
    pass


def set_wl():
    """Adjust irrigation time by percent based on historical climate data."""
    f = open("./data/levels.json", "r")  # Read the monthly percentages from file
    levels = json.load(f)
Example #32
0
    blockedPlugin = True
    pass

# local module imports
from blinker import signal
import gv  # Get access to SIP's settings, gv = global variables
from sip import template_render
from urls import urls  # Get access to SIP's URLs
import web
from webpages import ProtectedPage

# Add a new url to open the data entry page.
# fmt: off
urls.extend([
    u"/pcf857x", u"plugins.pcf857x.settings", u"/pcf857xj",
    u"plugins.pcf857x.settings_json", u"/pcf857xu", u"plugins.pcf857x.update",
    u"/pcf857xt", u"plugins.pcf857x.test", u"/pcf857x_scan",
    u"plugins.pcf857x.scan"
])
# fmt: on

# Add this plugin to the plugins menu
gv.plugin_menu.append([u"pcf857x", u"/pcf857x"])

pcf = {}
#prior = [0] * len(gv.srvals)
demo_mode = True

if platform.machine() == "armv6l" or platform.machine(
) == "armv7l":  # may be removed later but makes dev and testing possible without smbus
    demo_mode = False
Example #33
0
# !/usr/bin/env python
# -*- coding: utf-8 -*-

import web  # web.py framework
import gv  # Get access to SIP's settings
from helpers import *
from urls import urls  # Get access to SIP's URLs
from sip import template_render  #  Needed for working with web.py templates
from webpages import ProtectedPage  # Needed for security
import json  # for working with data file

# Add new URLs to access classes in this plugin.
# fmt: off
urls.extend([
    u"/proto-sp", u"plugins.proto.settings", u"/proto-save",
    u"plugins.proto.save_settings"
])
# fmt: on

# Add this plugin to the PLUGINS menu ["Menu Name", "URL"], (Optional)
gv.plugin_menu.append([_(u"Proto Plugin"), u"/proto-sp"])


def empty_function():  # Only a place holder
    """
    Functions defined here can be called by classes
    or run when the plugin is loaded. See comment at end.
    """
    pass

Example #34
0
import web
import gv  # Get access to SIP's settings
from urls import urls  # Get access to SIP's URLs
from sip import template_render
from webpages import ProtectedPage
from helpers import restart

installed = []

# Add new url(s).
# fmt: off
urls.extend([
    u"/plugins", u"plugins.plugin_manager.plugins", u"/upd-plugins",
    u"plugins.plugin_manager.update_plugins", u"/browse-plugins",
    u"plugins.plugin_manager.browse_plugins", u"/inst-plugins",
    u"plugins.plugin_manager.install_plugins", u"/pmr",
    u"plugins.plugin_manager.restart_page"
])
# fmt: on
# Add this plugin to the plugins menu
gv.plugin_menu.append([_(u"Manage Plugins"), u"/plugins"])


def get_permissions():
    global installed
    try:
        permissions = []
        files = subprocess.check_output([u"ls", u"plugins"])
        files = files.decode(u'utf-8')  #  to unicode string
        installed = [
Example #35
0
#!/usr/bin/env python

import web, json, time
import gv # Get access to ospi's settings
from urls import urls # Get access to ospi's URLs
try:
    from apscheduler.scheduler import Scheduler #This is a non-standard module. Needs to be installed in order for this feature to work.
except ImportError:
    pass

urls.extend(['/ma', 'plugins.monthly_adj.monthly_percent', '/uma', 'plugins.monthly_adj.update_percents']) # Add a new url to open the data entry page.
try:
    sched = Scheduler()
    sched.start() # Start the scheduler
except NameError:
    pass    
 
def set_wl():
    """Adjust irrigation time by percent based on historical climate data.""" 
    f = open('./data/levels.json', 'r') # Read the monthly percentages from file
    levels = json.load(f)
    f.close()
    mon = time.localtime().tm_mon # Get current month.
    gv.sd['wl'] = levels[mon-1] # Set the water level% (levels list is zero based).
    print 'Setting water level to {}%'.format(gv.sd['wl'])
    return

class monthly_percent:
    """Load an html page for entering monthly irrigation time adjustments"""
    def __init__(self):
        self.render = web.template.render('templates/')
Example #36
0
from __future__ import print_function
import web
from time import sleep
import gv  # Get access to SIP's settings
from urls import urls  # Get access to SIP's URLs
from sip import template_render  #  Needed for working with web.py templates
from helpers import stop_stations, jsave
from webpages import ProtectedPage  # Needed for security
from gpio_pins import set_output

# fmt: off
urls.extend([
    u"/puls",
    u"plugins.pulse_cct.pulse",
    u"/puls-run",
    u"plugins.pulse_cct.p_run",
    u"/puls-stop",
    u"plugins.pulse_cct.p_stop",
    u"/puls-sen",
    u"plugins.pulse_cct.p_save_enabled",
])
# fmt: on

gv.plugin_menu.append([u"Pulse Circuit", u"/puls"
                       ])  # Add this plugin to the home page plugins menu

stop = True


def chatter(cct):
    stop_stations()
    t = 0
Example #37
0
    "6",
    "7",
    "8",
    "9",
    "A",
    "B",
    "C",
    "D",
    "*",
    "#",
]

# Add new URLs to access classes in this plugin.
urls.extend([
    "/keypad-sp",
    "plugins.keypad.settings",
    "/keypad-save",
    "plugins.keypad.save_settings",
])

# Add this plugin to the PLUGINS menu ['Menu Name', 'URL'], (Optional)
gv.plugin_menu.append(["Keypad Plugin", "/keypad-sp"])


class ScanningKeypad:
    """ This class handles the keypad hardware """
    def __init__(self, pin_columns, pin_rows, indices, char_list):
        """
        Initializes a ScanningKeypad object
        Inputs: pin_columns - List of pin numbers for the keypad columns
                pin_rows - List of pin numbers for the keypad rows
                indices - A 2-dimensional table of the resulting index for each key when a column
Example #38
0
DATA_FILE = "./data/mqtt.json"

_client = None
_settings = {
    'broker_host': 'localhost',
    'broker_port': 1883,
    'broker_username': '******',
    'broker_password': '******',
    'publish_up_down': ''
}
_subscriptions = {}

# Add new URLs to access classes in this plugin.
urls.extend([
    '/mqtt-sp', 'plugins.mqtt.settings',
    '/mqtt-save', 'plugins.mqtt.save_settings'
    ])
gv.plugin_menu.append(['MQTT', '/mqtt-sp'])

NO_MQTT_ERROR = "MQTT plugin requires paho mqtt python library. On the command line run `pip install paho-mqtt` and restart SIP to get it."

class settings(ProtectedPage):
    """Load an html page for entering plugin settings.
    """
    def GET(self):
        settings = get_settings()
        return template_render.mqtt(settings, gv.sd[u'name'], NO_MQTT_ERROR if mqtt is None else "")  # open settings page

class save_settings(ProtectedPage):
    """Save user input to json file.
    Will create or update file when SUBMIT button is clicked
Example #39
0
import json
import time
import sys
import traceback

import web
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage
from helpers import stop_stations


# Add a new url to open the data entry page.
urls.extend(['/pressa', 'plugins.pressure_adj.settings',
             '/pressj', 'plugins.pressure_adj.settings_json',
             '/upressa', 'plugins.pressure_adj.update'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Pressure Monitor Settings', '/pressa'])

################################################################################
# GPIO input pullup:                                                           #
################################################################################

from gpio_pins import GPIO as GPIO

try:
    if gv.platform == 'pi':  # If this will run on Raspberry Pi:
        pin_pressure = 22
    elif gv.platform == 'bo':  # If this will run on Beagle Bone Black:
Example #40
0
auto_job = 0        # cron job that executes daily
daysWatched = 7     # number of days to consider when calculating water usage and rainfall data
metrics=englishmetrics

# zone history by date - a data structure
# { "date": <date>, [z0: inch, z1: inch, etc.] } 
# allows other modules to update settings
def updateSettings(m, d):
    global daysWatched
    global metrics
    # print "updateSettings:", d, m
    daysWatched = d
    metrics=m
    return

urls.extend(['/gu', 'plugins.graph_use.graph_use']) # Add a new url to open the data entry page
gv.plugin_menu.append(['Graph Water Use', '/gu']) # Add this plugin to the home page plugins menu
    

class graph_use:
    """Load an html page for entering extra wx settings"""
    def __init__(self):
        self.render = web.template.render('templates/', globals={'json':json,'sorted':sorted})
    
    def GET(self):
        zh = getZoneHistoryByDate(daysWatched)
        
        return self.render.graph_use(zh)

def getZoneHistoryByDate(limit):
    zh = []
Example #41
0
#!/usr/bin/env python

import web, json, time
import gv  # Get access to ospi's settings
from urls import urls  # Get access to ospi's URLs
try:
    from apscheduler.scheduler import Scheduler  #This is a non-standard module. Needs to be installed in order for this feature to work.
except ImportError:
    print "The Python module apscheduler could not be found."
    pass

urls.extend([
    '/ma', 'plugins.monthly_adj.monthly_percent', '/uma',
    'plugins.monthly_adj.update_percents'
])  # Add a new url to open the data entry page.

gv.plugin_menu.append(['Monthly Adjust',
                       '/ma'])  # Add this plugin to the home page plugins menu

try:
    sched = Scheduler()
    sched.start()  # Start the scheduler
except NameError:
    pass


def set_wl():
    """Adjust irrigation time by percent based on historical climate data."""
    f = open('./data/levels.json',
             'r')  # Read the monthly percentages from file
    levels = json.load(f)
Example #42
0
from threading import Thread
from random import randint
import time
from blinker import signal
import sys





json_data = './data/telegramBot.json'

# Add new URLs to access classes in this plugin.
urls.extend([
    '/telegramBot-sp', 'plugins.telegramBot.settings',
    '/telegramBot-save', 'plugins.telegramBot.save_settings'

    ])

gv.plugin_menu.append(['telegram Bot', '/telegramBot-sp'])


class SipBot(Thread):
    def __init__(self, globals):
        Thread.__init__(self)
        self.daemon = True
#        self.data = get_telegramBot_options()
        self.gv = globals
        self.bot = None
        self._currentChats = set([])
        self.start()
    return float(s)
  except:
    return 0

def mkdir_p(path):
    try:
        os.makedirs(path)
    except OSError as exc:  # Python >2.5
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            raise

# Add a new url to open the data entry page.
urls.extend(['/lwa',  'plugins.weather_level_adj.settings',
             '/lwj',  'plugins.weather_level_adj.settings_json',
             '/luwa', 'plugins.weather_level_adj.update'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Weather-based Water Level', '/lwa'])


################################################################################
# Main function loop:                                                          #
################################################################################

class WeatherLevelChecker(Thread):
    def __init__(self):
        Thread.__init__(self)
        self.daemon = True
        self.start()
Example #44
0
from webpages import ProtectedPage

# Load the Raspberry Pi GPIO (General Purpose Input Output) library
try:
    if gv.use_pigpio:
        import pigpio
        pi = pigpio.pi()
    else:
        import RPi.GPIO as GPIO
        pi = 0
except IOError:
    pass

# Add a new url to open the data entry page.
urls.extend(['/rb6', 'plugins.relay_6.settings',
# 	'/rbj16', 'plugins.relay_16.settings_json',
	'/rbu6', 'plugins.relay_6.update']) 

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Relay 6', '/rb6'])

params = {}

# Read in the parameters for this plugin from it's JSON file
def load_params():
    global params
    try:
        with open('./data/relay_6.json', 'r') as f:  # Read the settings from file
            params = json.load(f)
    except IOError: #  If file does not exist create file with defaults.
        params = {
Example #45
0
import gv  # Get access to ospi's settings, gv = global variables
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage

gv.use_gpio_pins = False  # Signal OSPi to not use GPIO pins

# Load the Raspberry Pi GPIO (General Purpose Input Output) library
try:
    import RPi.GPIO as GPIO
except IOError:
    pass

# Add a new url to open the data entry page.
urls.extend([
    '/rb', 'plugins.relay_board.settings', '/rbj',
    'plugins.relay_board.settings_json', '/rbu', 'plugins.relay_board.update'
])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Relay Board', '/rb'])

params = {}


# Read in the parameters for this plugin from it's JSON file
def load_params():
    global params
    try:
        with open('./data/relay_board.json',
                  'r') as f:  # Read the settings from file
            params = json.load(f)
Example #46
0
import json
import time
import sys
import traceback

import web
import gv  # Get access to sip's settings
from helpers import get_ip, uptime, reboot, poweroff, timestr, jsave, restart, stop_stations
from urls import urls  # Get access to sip's URLs
from sip import template_render
from webpages import ProtectedPage


# Add a new url to open the data entry page.
urls.extend(['/smsa', 'plugins.sms_adj.settings',
             '/smsj', 'plugins.sms_adj.settings_json',
             '/usmsa', 'plugins.sms_adj.update'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['SMS Settings', '/smsa'])

# Plugin system will catch the following error and disable the plugin automatically:
import gammu  # for SMS modem import gammu
# if no install modem and gammu visit: http://www.pihrt.com/elektronika/259-moje-rapsberry-pi-sms-ovladani-rpi
# USB modem HUAWEI E303 + SIM card with telephone provider

################################################################################
# Main function loop:                                                          #
################################################################################

Example #47
0
    print("\ttry: pip install paho-mqtt")
    mqtt = None

DATA_FILE = "./data/mqtt.json"

_client = None
_settings = {
    'broker_host': 'localhost',
    'broker_port': 1883,
    'publish_up_down': ''
}
_subscriptions = {}

# Add new URLs to access classes in this plugin.
urls.extend([
    '/mqtt-sp', 'plugins.mqtt.settings', '/mqtt-save',
    'plugins.mqtt.save_settings'
])
gv.plugin_menu.append(['MQTT', '/mqtt-sp'])

NO_MQTT_ERROR = "MQTT plugin requires paho mqtt python library. On the command line run `pip install paho-mqtt` and restart SIP to get it."


class settings(ProtectedPage):
    """Load an html page for entering plugin settings.
    """
    def GET(self):
        settings = get_settings()
        return template_render.mqtt(
            settings, gv.sd[u'name'],
            NO_MQTT_ERROR if mqtt is None else "")  # open settings page
Example #48
0
import hmac, hashlib
from base64 import b64encode

import web
import gv  # Get access to SIP's settings
from urls import urls  # Get access to SIP's URLs
from sip import template_render
from webpages import ProtectedPage
from helpers import stop_onrain

#  For testing only. Keeping this enabled will shorten the life of your SD card.
do_log = True  #  Change to True to enable, False to disable logging

# Add a new url to open the data entry page.
urls.extend([
    '/wa', 'plugins.weather_adj.settings', '/wj',
    'plugins.weather_adj.settings_json', '/uwa', 'plugins.weather_adj.update'
])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Weather-based Rain Delay', '/wa'])


def weather_to_delay(run_loop=False):
    if run_loop:
        t_start = gv.w_loop
        time.sleep(
            3
        )  # Sleep some time to prevent printing before startup information
    while True:
        data = get_weather_options()
        if data["auto_delay"] != "off":
Example #49
0
    return float(s)
  except:
    return 0

def mkdir_p(path):
    try:
        os.makedirs(path)
    except OSError as exc:  # Python >2.5
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            raise

# Add a new url to open the data entry page.
urls.extend(['/lwa',  'plugins.weather_level_adj.settings',
             '/lwj',  'plugins.weather_level_adj.settings_json',
             '/luwa', 'plugins.weather_level_adj.update'])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['Weather-based Water Level', '/lwa'])


################################################################################
# Main function loop:                                                          #
################################################################################

class WeatherLevelChecker(Thread):
    def __init__(self):
        Thread.__init__(self)
        self.daemon = True
        self.start()
Example #50
0
from threading import Thread
import json
import time

import web
import gv  # Get access to sip's settings
from urls import urls  # Get access to sip's URLs
from sip import template_render
from webpages import ProtectedPage


# Add a new url to open the data entry page.
# fmt: off
urls.extend(
    [
        u"/ma", u"plugins.monthly_adj.monthly_percent",
        u"/uma", u"plugins.monthly_adj.update_percents",
    ]
)
# fmt: on

# Add this plugin to the home page plugins menu
gv.plugin_menu.append([u"Monthly Adjust", u"/ma"])


def set_wl(run_loop=False):
    """Adjust irrigation time by percent based on historical climate data."""
    if run_loop:
        time.sleep(2)  # Sleep some time to prevent printing before startup information

    last_month = 0
    while True:
Example #51
0
from helpers import CPU_temperature, passwordHash, station_names
import web, json, re, os
import time, datetime, string
import gv # Gain access to ospy's settings
from urls import urls # Gain access to ospy's URL list
from webpages import ProtectedPage

##############
## New URLs ##

urls.extend([
    '/jo', 'plugins.mobile_app.options',
    '/jc', 'plugins.mobile_app.cur_settings',
    '/js', 'plugins.mobile_app.station_state',
    '/jp', 'plugins.mobile_app.program_info',
    '/jn', 'plugins.mobile_app.station_info',
    '/jl', 'plugins.mobile_app.get_logs',
    '/sp', 'plugins.mobile_app.set_password'])

#######################
## Class definitions ##

class options(object): # /jo
    """Returns device options as json."""
    def GET(self):
        web.header('Access-Control-Allow-Origin', '*')
        web.header('Content-Type', 'application/json')
        web.header('Cache-Control', 'no-cache')
        jopts = {
            "fwv" : gv.ver_str+'-OSPi',
            "tz": gv.sd['tz'],
Example #52
0
# local module imports
from helpers import get_cpu_temp, check_login #  , password_hash
import gv  # Gain access to sip's settings
from urls import urls  # Gain access to sip's URL list
import web
from webpages import ProtectedPage, WebPage

##############
## New URLs ##

# fmt: off
urls.extend([
    u"/jo", u"plugins.mobile_app.options",
    u"/jc", u"plugins.mobile_app.cur_settings",
    u"/js", u"plugins.mobile_app.station_state",
    u"/jp", u"plugins.mobile_app.program_info",
    u"/jn", u"plugins.mobile_app.station_info",
    u"/jl", u"plugins.mobile_app.get_logs",
    u"/sp", u"plugins.mobile_app.set_password"])
# fmt: on

#######################
## Class definitions ##


class options(WebPage):  # /jo
    """Returns device options as json."""

    def GET(self):
        web.header(b"Access-Control-Allow-Origin", b"*")
        web.header(b"Content-Type", b"application/json")
Example #53
0
    """
    try:
        os.makedirs(path)
    except OSError as exc:
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            raise


# Add a new url to open the data entry page.
# fmt: off
urls.extend(
    [
        u"/lwa", u"plugins.weather_level_adj.settings",
        u"/lwj", u"plugins.weather_level_adj.settings_json",
        u"/luwa", u"plugins.weather_level_adj.update",
    ]
)
# fmt: on

# Add this plugin to the home page plugins menu
gv.plugin_menu.append([_(u"Weather-based Water Level"), u"/lwa"])

lwa_options = {}
lwa_decipher = {}
prior = {u"temp_cutoff": 0, u"water_needed": 0, u"daily_irrigation": 0}


################################################################################
# Main function loop:                                                          #
Example #54
0
# !/usr/bin/env python

import time

import gv
from gpio_pins import GPIO, pin_relay
from urls import urls
import web
from webpages import ProtectedPage


urls.extend(['/tr', 'plugins.relay.toggle_relay'])  # Add a new url for this plugin.

gv.plugin_menu.append(['Test Relay', '/tr'])  # Add this plugin to the home page plugins menu


class toggle_relay(ProtectedPage):
    """Test relay by turning it on for a short time, then off."""
    def GET(self):
        try:
            GPIO.output(pin_relay, GPIO.HIGH)  # turn relay on
            time.sleep(3)
            GPIO.output(pin_relay, GPIO.LOW)  # Turn relay off
        except Exception:
            pass
        raise web.seeother('/')  # return to home page
Example #55
0
from random import randint
import json
import time
import sys
import traceback

import web
import gv  # Get access to ospi's settings
from helpers import get_ip, uptime, reboot, poweroff, timestr, jsave, restart
from urls import urls  # Get access to ospi's URLs
from ospi import template_render
from webpages import ProtectedPage

# Add a new url to open the data entry page.
urls.extend([
    '/smsa', 'plugins.sms_adj.settings', '/smsj',
    'plugins.sms_adj.settings_json', '/usmsa', 'plugins.sms_adj.update'
])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append(['SMS Settings', '/smsa'])

# Plugin system will catch the following error and disable the plugin automatically:
import gammu  # for SMS modem import gammu
# if no install modem and gammu visit: http://www.pihrt.com/elektronika/259-moje-rapsberry-pi-sms-ovladani-rpi
# USB modem HUAWEI E303 + SIM card with telephone provider

################################################################################
# Main function loop:                                                          #
################################################################################

Example #56
0
import time
import subprocess
import sys
import traceback
import json

import web
import gv  # Get access to SIP's settings
from urls import urls  # Get access to SIP's URLsimport errno
from sip import template_render
from webpages import ProtectedPage
from helpers import restart

# Add a new url to open the data entry page.
urls.extend(['/UPs', 'plugins.system_update.status_page',
             '/UPu', 'plugins.system_update.update_page'
             ])

# Add this plugin to the home page plugins menu
gv.plugin_menu.append([_('System update'), '/UPs'])


class StatusChecker():
    def __init__(self):

        self.status = {
            'ver_str': gv.ver_str,
            'ver_date': gv.ver_date,
            'status': '',
            'remote': 'None!',
            'can_update': False}