question

PVTex avatar image
PVTex asked

Help needed: Power Meter lib for Modbus-based meters WS100

Hello,


i have created the new device WS100

ws100.py
import logging

import device
import probe
from register import *

log = logging.getLogger()

class ws100_Meter(device.EnergyMeter):
    productid = 0xb017
    productname = 'WS100 Meter'
    min_timeout = 0.5

    def __init__(self, *args):
        super(ws100_Meter, self).__init__(*args)

        self.info_regs = [
            Reg_text(0x1000, 4,'/Serial'),
            Reg_u16b(0x1004, '/FirmwareVersion'),
        ]

    def device_init(self):
        self.data_regs = [
            Reg_u32b(0x0104, '/Ac/Power',          100, '%.1f W'),
            Reg_u16b(0x010a, '/Ac/Frequency',      100, '%.1f Hz'),
            Reg_u32b(0x010e, '/Ac/Energy/Forward', 100, '%.1f kWh'),
            Reg_u32b(0x0118, '/Ac/Energy/Reverse', 100, '%.1f kWh'),

            # We always have L1 voltage and current
            Reg_u32b(0x0100, '/Ac/L1/Voltage',      10, '%.1f V'),
            Reg_u32b(0x0102, '/Ac/L1/Current',     100, '%.1f A'),
            Reg_u32b(0x0104, '/Ac/L1/Power',          100, '%.1f W'),
            Reg_u32b(0x010e, '/Ac/L1/Energy/Forward', 100, '%.1f kWh'),
            Reg_u32b(0x0118, '/Ac/L1/Energy/Reverse', 100, '%.1f kWh'),
        ]

    def get_ident(self):
        return 'ws100_%s' % self.info['/Serial']


models = {
    0x07000015 : { # WS100 (0x0091 2224 0700 0015) 
        'model':    'WS100_21',
        'handler':  ws100_Meter,
    },
    0x006970016 : { # WS100 (0x0091 2224 0700 0015)
        'model':    'WS100_22',
        'handler':  ws100_Meter,
    },
    0x05920017 : { # WS100 (0x0091 2224 0700 0015)
        'model':    'WS100_23',
        'handler':  ws100_Meter,
    },
    0x11720018 : { # WS100 (0x0091 2224 0700 0015)
        'model':    'WS100_24',
        'handler':  ws100_Meter,
    },
    0x11710019 : { # WS100 (0x0091 2224 0700 0015)
        'model':    'WS100_25',
        'handler':  ws100_Meter,
    },
    0x1179001a : { # WS100 (0x0091 2224 0700 0015)
        'model':    'WS100_26',
        'handler':  ws100_Meter,
    },
    0x0460001f : { # WS100 (0x0091 2224 0700 0015)
        'model':    'WS100_31',
        'handler':  ws100_Meter,
    },
    0x06990020 : { # WS100 (0x0091 2224 0700 0015)
        'model':    'WS100_32',
        'handler':  ws100_Meter,
    },
}

probe.add_handler(probe.ModelRegister(Reg_u32b(0x1002), models,
                                      methods=['rtu','tcp'],
                                      units=[21, 22, 23, 24, 25, 26, 31, 32]))


the new device is found:

@4000000064d35da3374642cc INFO     Found WS100_22 at tcp:192.168.88.186:502:22
@4000000064d35da51a0863fc INFO     Found WS100_21 at tcp:192.168.88.186:502:21
@4000000064d35da60ceac14c INFO     Found WS100_31 at tcp:192.168.88.186:502:31
@4000000064d35da702f3ddf4 INFO     Found WS100_32 at tcp:192.168.88.186:502:32

but it is not displayed in the device list.

what have i done wrong?

Energy MeterModbus TCPpower meter
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

0 Answers

Related Resources

Energy Meter Selection Guide

Additional resources still need to be added for this topic

Modbus TCP Basics