Exemple #1
0
def test_default_packet_as_array():
    p = P1Packet(NORMAL_PACKET.split('\n'))
    assert p['header'] == '/ISk5\2ME382-1004'
    assert p['kwh']['eid'] == '4B414C37303035313135383130323132'
    assert p['kwh']['low']['consumed'] == 608.400
    assert p['kwh']['high']['consumed'] == 490.342
    assert p['kwh']['low']['produced'] == 0.001
    assert p['kwh']['high']['produced'] == 0
    assert p['kwh']['tariff'] == 1
    assert p['kwh']['current_consumed'] == 1.51
    assert p['kwh']['current_produced'] == 0
    assert p['kwh']['treshold'] == 999
    assert p['kwh']['switch'] == 1
    assert p['msg']['code'] == None
    assert p['msg']['text'] == None
    assert p['gas']['device_type'] == 3
    assert p['gas']['eid'] == '3238303131303031323332313337343132'
    assert p['gas']['total'] == 947.680
    assert p['gas']['valve'] == 1
    assert str(p) == NORMAL_PACKET
Exemple #2
0
def test_default_packet_as_array():
    p = P1Packet(NORMAL_PACKET.split('\n'))
    assert p['header'] == '/ISk5\2ME382-1004'
    assert p['kwh']['eid'] == 'XXXXXXXXXXXXXXMYSERIALXXXXXXXXXXXXXX'
    assert p['kwh']['low']['consumed'] == 608.400
    assert p['kwh']['high']['consumed'] == 490.342
    assert p['kwh']['low']['produced'] == 0.001
    assert p['kwh']['high']['produced'] == 0
    assert p['kwh']['tariff'] == 1
    assert p['kwh']['current_consumed'] == 1.51
    assert p['kwh']['current_produced'] == 0
    assert p['kwh']['treshold'] == 999
    assert p['kwh']['switch'] == 1
    assert p['msg']['code'] == None
    assert p['msg']['text'] == None
    assert p['gas']['device_type'] == 3
    assert p['gas']['eid'] == '3238303131303031323332313337343132'
    assert p['gas']['total'] == 947.680
    assert p['gas']['valve'] == 1
    assert str(p) == NORMAL_PACKET
Exemple #3
0
def test_meter_read_one_packet():
    serial.Serial = SerialMock
    meter = SmartMeter('/dev/ttyUSB0')
    meter.serial.lines_in_buffer = NORMAL_PACKET.splitlines(True)

    p = meter.read_one_packet()
    assert p['header'] == '/ISk5\2ME382-1004'
    assert p['kwh']['eid'] == 'XXXXXXXXXXXXXXMYSERIALXXXXXXXXXXXXXX'
    assert p['kwh']['low']['consumed'] == 608.400
    assert p['kwh']['high']['consumed'] == 490.342
    assert p['kwh']['low']['produced'] == 0.001
    assert p['kwh']['high']['produced'] == 0
    assert p['kwh']['tariff'] == 1
    assert p['kwh']['current_consumed'] == 1.51
    assert p['kwh']['current_produced'] == 0
    assert p['kwh']['treshold'] == 999
    assert p['kwh']['switch'] == 1
    assert p['msg']['code'] == None
    assert p['msg']['text'] == None
    assert p['gas']['device_type'] == 3
    assert p['gas']['eid'] == '3238303131303031323332313337343132'
    assert p['gas']['total'] == 947.680
    assert p['gas']['valve'] == 1
    assert p._datagram == NORMAL_PACKET
Exemple #4
0
def test_meter_read_one_packet():
    serial.Serial = SerialMock
    meter = SmartMeter('/dev/ttyUSB0')
    meter.serial.lines_in_buffer = NORMAL_PACKET.split('\n')

    p = meter.read_one_packet()
    assert p['header'] == '/ISk5\2ME382-1004'
    assert p['kwh']['eid'] == '4B414C37303035313135383130323132'
    assert p['kwh']['low']['consumed'] == 608.400
    assert p['kwh']['high']['consumed'] == 490.342
    assert p['kwh']['low']['produced'] == 0.001
    assert p['kwh']['high']['produced'] == 0
    assert p['kwh']['tariff'] == 1
    assert p['kwh']['current_consumed'] == 1.51
    assert p['kwh']['current_produced'] == 0
    assert p['kwh']['treshold'] == 999
    assert p['kwh']['switch'] == 1
    assert p['msg']['code'] == None
    assert p['msg']['text'] == None
    assert p['gas']['device_type'] == 3
    assert p['gas']['eid'] == '3238303131303031323332313337343132'
    assert p['gas']['total'] == 947.680
    assert p['gas']['valve'] == 1
    assert str(p) == NORMAL_PACKET