kipe / enocean

Python library for EnOcean serial protocol
MIT License
70 stars 101 forks source link

ubiwizz "MICITRV004-QM" Profile A5-20-01 #80

Open kapwebdr opened 5 years ago

kapwebdr commented 5 years ago

Hi,

I try to communicate with this EnOcean Thermostat, I can read packet, but i can't set a new target temp.

I think the problem was link to the learn function.

My question is probably stupid and i'm sure it's easy but, how can i put the controller in teach-in ?

And after what packet i need to send to set the target temp. I don't receive all data (contain in the eep ) from the device, only current temp and target temp...

Really sorry, but i try to add this device in home assistant.

My test code :

`#!/home/hass/homeassistant/bin/python3

-- encoding: utf-8 --

from enocean.consolelogger import init_logging import enocean.utils from enocean.communicators.serialcommunicator import SerialCommunicator from enocean.protocol.packet import RadioPacket from enocean.protocol.constants import PACKET, RORG import sys import traceback

try: import queue except ImportError: import Queue as queue

def assemble_radio_packet(transmitter_id): return RadioPacket.create(rorg=RORG.BS4, rorg_func=0x20, rorg_type=0x01, sender=transmitter_id, destination=[0x05, 0x06, 0x78, 0xBE], TMP=20)

init_logging() communicator = SerialCommunicator('/dev/ttyS1') communicator.teach_in = True communicator.start() print('The Base ID of your module is %s.' % enocean.utils.to_hex_string(communicator.base_id))

if communicator.base_id is not None: print('Sending example package.') communicator.send(assemble_radio_packet(communicator.base_id))

endless loop receiving radio packets

while communicator.is_alive(): try:

Loop to empty the queue...

    packet = communicator.receive.get(block=True, timeout=1)

    if packet.packet_type == PACKET.RADIO and packet.rorg == RORG.BS4:
        # parse packet with given FUNC and TYPE
        for k in packet.parse_eep(0x02, 0x05):
            print('%s: %s' % (k, packet.parsed[k]))
    if packet.packet_type == PACKET.RADIO and packet.rorg == RORG.BS1:
        # alternatively you can select FUNC and TYPE explicitely
        packet.select_eep(0x00, 0x01)
        # parse it
        packet.parse_eep()
        for k in packet.parsed:
            print('%s: %s' % (k, packet.parsed[k]))
    if packet.packet_type == PACKET.RADIO and packet.rorg == RORG.RPS:
        for k in packet.parse_eep(0x02, 0x02):
            print('%s: %s' % (k, packet.parsed[k]))
except queue.Empty:
    continue
except KeyboardInterrupt:
    break
except Exception:
    traceback.print_exc(file=sys.stdout)
    break

if communicator.is_alive(): communicator.stop()`

kapwebdr commented 5 years ago

Hi,

I work on this device, i found how to get all the data from the eep, my mistake, i don't choose the correct FUNC and TYP when i parse_eep .

But i still have a problem for link the controller to the device (for send message) (For information this device is the same that Micropelt MVA004) I read the doc of the micropelt device, but not found what i need to do to teach-in with the controller.

I execute the example file "example_DO21-11B-E.py" without the turn_on and turn_off command, but when i put the device in teach mode i d'ont receive an RORG = UTE, but a simply RORG=BS4

My test script : `#!/home/hass/homeassistant/bin/python3

-- encoding: utf-8 --

from enocean.consolelogger import init_logging import enocean.utils from enocean.communicators.serialcommunicator import SerialCommunicator from enocean.protocol.packet import RadioPacket from enocean.protocol.packet import Packet

from enocean.protocol.constants import PACKET, RORG import sys import traceback

try: import queue except ImportError: import Queue as queue

def send_command_temp(destination, output_value): global communicator communicator.send( RadioPacket.create(rorg=RORG.BS4, rorg_func=0x20, rorg_type=0x01, destination=destination, CV=50, sender=communicator.base_id, TMP=output_value) )

def target_temp(destination): send_command_temp(destination, 2)

init_logging() communicator = SerialCommunicator('/dev/ttyS1') communicator.teach_in = True communicator.learn = True communicator.start() print('The Base ID of your module is %s.' % enocean.utils.to_hex_string(communicator.base_id)) target_temp([0x05, 0x06, 0x78, 0xBE])

endless loop receiving radio packets

while communicator.is_alive(): try:

Loop to empty the queue...

    packet = communicator.receive.get(block=True, timeout=1)

    if packet.packet_type == PACKET.RADIO and packet.rorg == RORG.BS4:
        # parse packet with given FUNC and TYPE
        for k in packet.parse_eep(0x20, 0x01):
            print('%s: %s 1' % (k, packet.parsed[k]))
except queue.Empty:
    continue
except KeyboardInterrupt:
    break
except Exception:
    traceback.print_exc(file=sys.stdout)
    break

if communicator.is_alive(): communicator.stop() `

The response :

2018-09-28 15:23:44,281 - enocean.protocol.packet - DEBUG - 165 2018-09-28 15:23:44,282 - enocean.protocol.packet - DEBUG - RORG.UTE 2018-09-28 15:23:44,282 - enocean.protocol.packet - DEBUG - learn received, EEP detected, RORG: 0xA5, FUNC: 0x20, TYPE: 0x01, Manufacturer: 0x6A 2018-09-28 15:23:44,283 - enocean.communicators.SerialCommunicator - DEBUG - 05:06:78:BE->FF:FF:FF:FF (-80 dBm): 0x01 ['0xa5', '0x80', '0x8', '0x6a', '0x80', '0x5', '0x6', '0x78', '0xbe', '0x0'] ['0x1', '0xff', '0xff', '0xff', '0xff', '0x50', '0x0'] OrderedDict() CV: {'description': 'Current Value', 'unit': '%', 'value': 128.0, 'raw_value': 128} 1 SO: {'description': 'Service On', 'unit': '', 'value': 'off', 'raw_value': 0} 1 ENIE: {'description': 'Energy input enabled', 'unit': '', 'value': 'false', 'raw_value': 0} 1 ES: {'description': 'Energy storage sufficiently charged', 'unit': '', 'value': 'false', 'raw_value': 0} 1 BCAP: {'description': 'Battery capacity; change battery next days', 'unit': '', 'value': 'false', 'raw_value': 0} 1 CCO: {'description': 'Contact, cover open', 'unit': '', 'value': 'true', 'raw_value': 1} 1 FTS: {'description': 'Failure Temperature sensor, out of range', 'unit': '', 'value': 'false', 'raw_value': 0} 1 DWO: {'description': 'Detection, window open', 'unit': '', 'value': 'false', 'raw_value': 0} 1 ACO: {'description': 'Actuator obstructed', 'unit': '', 'value': 'false', 'raw_value': 0} 1 TMP: {'description': 'Temperature (linear)', 'unit': '°C', 'value': 16.627450980392158, 'raw_value': 106} 1 LRNB: {'description': 'LRN Bit', 'unit': '', 'value': 'Teach-in telegram', 'raw_value': 0} 1 2018-09-28 15:23:46,473 - enocean.protocol.packet - DEBUG - 165 2018-09-28 15:23:46,473 - enocean.protocol.packet - DEBUG - RORG.UTE 2018-09-28 15:23:46,474 - enocean.communicators.SerialCommunicator - DEBUG - 05:06:78:BE->FF:FF:FF:FF (-82 dBm): 0x01 ['0xa5', '0x0', '0x30', '0x8d', '0x8', '0x5', '0x6', '0x78', '0xbe', '0x0'] ['0x1', '0xff', '0xff', '0xff', '0xff', '0x52', '0x0'] OrderedDict() CV: {'description': 'Current Value', 'unit': '%', 'value': 0.0, 'raw_value': 0} 1 SO: {'description': 'Service On', 'unit': '', 'value': 'off', 'raw_value': 0} 1 ENIE: {'description': 'Energy input enabled', 'unit': '', 'value': 'false', 'raw_value': 0} 1 ES: {'description': 'Energy storage sufficiently charged', 'unit': '', 'value': 'true', 'raw_value': 1} 1 BCAP: {'description': 'Battery capacity; change battery next days', 'unit': '', 'value': 'true', 'raw_value': 1} 1 CCO: {'description': 'Contact, cover open', 'unit': '', 'value': 'false', 'raw_value': 0} 1 FTS: {'description': 'Failure Temperature sensor, out of range', 'unit': '', 'value': 'false', 'raw_value': 0} 1 DWO: {'description': 'Detection, window open', 'unit': '', 'value': 'false', 'raw_value': 0} 1 ACO: {'description': 'Actuator obstructed', 'unit': '', 'value': 'false', 'raw_value': 0} 1 TMP: {'description': 'Temperature (linear)', 'unit': '°C', 'value': 22.11764705882353, 'raw_value': 141} 1 LRNB: {'description': 'LRN Bit', 'unit': '', 'value': 'Data telegram', 'raw_value': 1} 1

kapwebdr commented 5 years ago

Hi,

I still have trouble to work with A5-20-01 profile, i don't understand how to pair the device, with Bidirectional Teach-In / Teach-Out.

It's work on Fhem, but i really want to work with Python.

Can you tell me how i can do to put in teach mod and send the correct packet to the device ?

Fhem Code :

` # bidirectional 4BS teach-in if ($st eq "hvac.01" || $st eq "MD15") {

EEP A5-20-01

            $attr{$name}{comMode} = "biDir";
            $attr{$name}{destinationID} = "unicast";
            ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
            # teach-in response
            EnOcean_SndRadio(undef, $hash, $packetType, $rorg, "800FFFF0", $subDef, "00", $hash->{DEF});
            Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
            readingsSingleUpdate($hash, 'operationMode', 'setpointTemp', 0);

}`

Thanks by advance ;)

benjitokun commented 4 years ago

Hi, I am facing same problem. Do you have an update? Thanks in advance