Beispiel #1
0
 def __init__(self):
     self.logger = logging.getLogger('nl.oppleo.utils.BackupUtil')
     self.oppleoConfig = OppleoConfig()
     self.oppleoSystemConfig = OppleoSystemConfig()
     self.monitorThread = None
     self.singleBackupThread = None
     self.stop_event = threading.Event()
     self.lock = threading.Lock()
Beispiel #2
0
 def __init__(self, energy_device_id, appSocketIO=None):
     self.logger = logging.getLogger(
         'nl.oppleo.services.EnergyModbusReader')
     self.energy_device_id = energy_device_id
     self.appSocketIO = appSocketIO
     self.oppleoConfig: OppleoConfig = OppleoConfig()
     self.logger.debug('Production environment, calling initInstrument()')
     self.initInstrument()
     self.threadLock = threading.Lock()
Beispiel #3
0
import logging

from nl.oppleo.config.OppleoSystemConfig import OppleoSystemConfig
from nl.oppleo.config.OppleoConfig import OppleoConfig
from nl.oppleo.services.PushMessageProwl import PushMessageProwl

oppleoSystemConfig = OppleoSystemConfig()
oppleoConfig = OppleoConfig()


class PushMessage(object):
    logger = logging.getLogger('nl.oppleo.services.PushMessage')

    priorityVeryLow = -2
    priorityModerate = -1
    priorityNormal = 0
    priorityHigh = 1
    priorityEmergency = 2

    @staticmethod
    def sendMessage(title, message, priority=priorityNormal):
        global oppleoConfig

        PushMessage.logger.debug("sendMessage()")
        if oppleoSystemConfig.prowlEnabled:
            PushMessageProwl.sendMessage(title=title,
                                         message=message,
                                         priority=priority,
                                         apiKey=oppleoSystemConfig.prowlApiKey,
                                         chargerName=oppleoConfig.chargerName)
Beispiel #4
0
from nl.oppleo.daemon.VehicleChargeStatusMonitorThread import VehicleChargeStatusMonitorThread
from nl.oppleo.config.OppleoConfig import OppleoConfig

oppleoConfig = OppleoConfig()
oppleoConfig.connectedClients['ABC'] = {
                                    'sid'   : 'ABC',
                                    'auth'  : True, # Authenticated
                                    'stats' : 'connected'
                                    }

vsmt = VehicleChargeStatusMonitorThread()
vsmt.rfid = '584190412223'

# Speed stuff up a bit
vsmt._VehicleChargeStatusMonitorThread__vehicleMonitorInterval = 3

vsmt.monitor()

Beispiel #5
0
import logging
from nl.oppleo.config.OppleoSystemConfig import OppleoSystemConfig
from nl.oppleo.config.OppleoConfig import OppleoConfig
from nl.oppleo.utils.ModulePresence import modulePresence
from nl.oppleo.services.led.RGBLedControllerThread import RGBLedControllerThread

oppleoSystemConfig = OppleoSystemConfig()
oppleoConfig = OppleoConfig()

print("RGB Led simulator")

GPIO = modulePresence.GPIO
# We are the only GPIO user, ignore warnings
GPIO.setwarnings(False)
# Set pin mode to BCM. Normally done in Oppleo.py main file
GPIO.setmode(GPIO.BCM)

oppleoConfig.rgblcThread = RGBLedControllerThread()

print("Starting RGBLedControllerThread...")
oppleoConfig.rgblcThread.start()

run = True
while run:

    try:
        option = input(
            "Please state 'open', 'close', 'charge', 'nocharge', 'error' or 'flash' or 'stop':"
        )
        if option.upper() in [
                'OPEN', 'CLOSE', 'CHARGE', 'NOCHARGE', 'ERROR', 'NOERROR',
"""
 This is an example using the UpdateOdometerTeslaUtil helper class to 
 update the charge session in the database with the odometer (km stand)
 at this moment.
 
 It fetches the RFID from the charge session, checks for an active 
 OAuth token and uses that to login, get's the selected vehicle from the 
 RFID and fetches the odo value. This value is added to the charge session.
 
 This should be run at the start of the charge session

 The TeslaApi is quite slow, so the helper creates a thread and executes in 
 its own thread. It needs to run in an environment where this is allowed and
 threads are enabled.
 """
oppleoConfig = OppleoConfig()

# app initiliazation
app = Flask(__name__)
# Make it available through oppleoConfig
oppleoConfig.app = app
appSocketIO = SocketIO(app)
# Make it available through oppleoConfig
oppleoConfig.appSocketIO = appSocketIO

# Instantiate the helper object
uotu = UpdateOdometerTeslaUtil()
# Hand it the session id, the id from ChargeSessionModel
# This example uses 12 as this is the oldest in the local database
uotu.set_charge_session_id(194)
# Start the helper.
Beispiel #7
0
oppleoLogger = logging.getLogger('nl.oppleo.webapp.Oppleo')
oppleoLogger.debug('Initializing Oppleo...')

import sys
print('Reporting sys.version %s : ' % sys.version)
oppleoLogger.debug('sys.version %s : ' % sys.version)

from nl.oppleo.exceptions.Exceptions import DbException

from functools import wraps

try:
    from nl.oppleo.models.Base import Base
    from nl.oppleo.webapp.WebSocketQueueReaderBackgroundTask import WebSocketQueueReaderBackgroundTask
    from nl.oppleo.config.OppleoConfig import OppleoConfig
    oppleoConfig = OppleoConfig()
    oppleoSystemConfig.chargerName = oppleoConfig.chargerName

    from nl.oppleo.services.PushMessage import PushMessage

    if modulePresence.gpioAvailable():
        GPIO = modulePresence.GPIO
        try:
            if oppleoConfig.gpioMode == "BOARD":
                oppleoLogger.info("Setting GPIO MODE to BOARD")
                GPIO.setmode(GPIO.BOARD)
            else:
                oppleoLogger.info("Setting GPIO MODE to BCM")
                GPIO.setmode(GPIO.BCM)
            # No warnings
            GPIO.setwarnings(False)