Example #1
0
def get_charger_data(registers):
    client = EPsolarTracerClient(serialclient=None)
    client.connect()
    output = dict()
    for key in registers.iterkeys():
        value = client.read_input(key)
        output[key] = {'name': value.register.name, 'description': value.register.description, 'value': value.value}
    client.close()
    return output
Example #2
0
def createclient(port):
    # print 'creating client for',port
    # creates a client and appends to clients list
    try:
        client = EPsolarTracerClient(method='rtu',
                                     port=port,
                                     baudrate=115200,
                                     timeout=0.2)
        #need to do a check to make sure device is on as it fails if unit is not on or conected to cable
        # print client
        client.connect()
        sleep(1)
        unitid = getunitid(client)
        # print client, unitid
        clients.append(client)
        return client
    except AssertionError as error:
        # print 'error connecting',error
        return
Example #3
0
#
# Set time on charge controllers based on local time while running this script
# comment/uncomment write commands below to view or set time
#
from pyepsolartracer.client import EPsolarTracerClient
from pyepsolartracer.registers import registers, coils, registerByName
from pymodbus.client.sync import ModbusSerialClient

ports = ['/dev/ttyXRUSB0', '/dev/ttyXRUSB1']

for port in ports:
    print "************ " + port + " ***************"
    serialclient = ModbusSerialClient(method='rtu', port=port, baudrate=115200)
    client = EPsolarTracerClient(serialclient=serialclient)
    client.connect()

    import datetime
    now = datetime.datetime.now()

    print now.year, now.month, now.day, now.hour, now.minute, now.second

    yearAndMonth = int(((now.year - 2000) << 8) | now.month)
    dayAndHour = int(((now.day) << 8) | now.hour)
    minuteAndSecond = int(((now.minute) << 8) | now.second)

    #register = registerByName("Real time clock 1")
    #print vars(register)

    addr = 0x9013
    vals = [minuteAndSecond, dayAndHour, yearAndMonth]
Example #4
0
# -*- coding: iso-8859-15 -*-


# This reads severals values from the EPSolar-charging-controller via RS485-USB-Cable (correct kernel-driver-module needed)

from pyepsolartracer.client import EPsolarTracerClient
import json

# configure the client logging
import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.INFO)

client = EPsolarTracerClient(port = '/dev/ttyUSB0')
if client.connect() == False:
    print("Error. Port not able to be opened")


data = []  # New List for Data

response = client.read_device_info()

#data.append(["Device Info"])  # Root Layer
#data[0].append(
data.append(
    {
        'con-manufacturer':repr(response.information[0]),
        'con-model':repr(response.information[1]),
        'con-version':repr(response.information[2]),
        'con-temp-controller':client.read_input("Temperature inside equipment").value,