From e9c5a712886042aae6796f218a66d572fc22484b Mon Sep 17 00:00:00 2001 From: Vincent Saluzzo Date: Sun, 21 Oct 2018 15:56:24 +0200 Subject: [PATCH 1/4] add ability to manage D2-05-00 EEP profile (roller shutter nodon for example) --- .gitignore | 2 + enocean/communicators/serialcommunicator.py | 2 +- enocean/protocol/EEP.xml | 91 +++++++++++++++++++++ examples/enocean_example.py | 6 +- examples/example_D2-05-00.py | 64 +++++++++++++++ 5 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 examples/example_D2-05-00.py diff --git a/.gitignore b/.gitignore index 654e540..2bb1c65 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ man MANIFEST dist pip-selfcheck.json + +.vscode/ diff --git a/enocean/communicators/serialcommunicator.py b/enocean/communicators/serialcommunicator.py index ffe4201..e67e4a5 100644 --- a/enocean/communicators/serialcommunicator.py +++ b/enocean/communicators/serialcommunicator.py @@ -11,7 +11,7 @@ class SerialCommunicator(Communicator): ''' Serial port communicator class for EnOcean radio ''' logger = logging.getLogger('enocean.communicators.SerialCommunicator') - def __init__(self, port='/dev/ttyAMA0', callback=None): + def __init__(self, port='/dev/tty.usbserial-FT1SEG3T', callback=None): super(SerialCommunicator, self).__init__(callback) # Initialize serial port self.__ser = serial.Serial(port, 57600, timeout=0.1) diff --git a/enocean/protocol/EEP.xml b/enocean/protocol/EEP.xml index 067bbeb..2886ff2 100644 --- a/enocean/protocol/EEP.xml +++ b/enocean/protocol/EEP.xml @@ -1035,5 +1035,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/enocean_example.py b/examples/enocean_example.py index b3b220e..e1e6d21 100755 --- a/examples/enocean_example.py +++ b/examples/enocean_example.py @@ -36,7 +36,11 @@ def assemble_radio_packet(transmitter_id): try: # Loop to empty the queue... packet = communicator.receive.get(block=True, timeout=1) - + if packet.packet_type == PACKET.RADIO and packet.rorg == RORG.VLD: + packet.select_eep(0x05, 0x00) + 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.BS4: # parse packet with given FUNC and TYPE for k in packet.parse_eep(0x02, 0x05): diff --git a/examples/example_D2-05-00.py b/examples/example_D2-05-00.py new file mode 100644 index 0000000..bb03566 --- /dev/null +++ b/examples/example_D2-05-00.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- +''' +Example to show automatic UTE Teach-in responses using +http://www.g-media.fr/prise-gigogne-enocean.html + +Waits for UTE Teach-ins, sends the response automatically and prints the ID of new device. +''' + +import sys +import time +import traceback +import enocean.utils +from enocean.communicators import SerialCommunicator +from enocean.protocol.packet import RadioPacket, UTETeachIn +from enocean.protocol.constants import RORG + +try: + import queue +except ImportError: + import Queue as queue + + +def set_position(destination, percentage): + global communicator + communicator.send( + RadioPacket.create(rorg=RORG.VLD, rorg_func=0x05, rorg_type=0x00, destination=destination, sender=communicator.base_id, command=1, POS=percentage) + ) + + + +communicator = SerialCommunicator() +communicator.start() +print('The Base ID of your module is %s.' % enocean.utils.to_hex_string(communicator.base_id)) + + +# set_position([0x05, 0x0F, 0x0B, 0xEA], 100) +# time.sleep(10) +set_position([0x05, 0x0F, 0x0B, 0xEA], 50) + + +print('Press and hold the teach-in button on the plug now, till it starts turning itself off and on (about 10 seconds or so...)') +devices_learned = [] + +# endless loop receiving radio packets +while communicator.is_alive(): + try: + # Loop to empty the queue... + packet = communicator.receive.get(block=True, timeout=1) + if isinstance(packet, UTETeachIn): + print('New device learned! The ID is %s.' % (packet.sender_hex)) + devices_learned.append(packet.sender) + except queue.Empty: + continue + except KeyboardInterrupt: + break + except Exception: + traceback.print_exc(file=sys.stdout) + break + +print('Devices learned during this session: %s' % (', '.join([enocean.utils.to_hex_string(x) for x in devices_learned]))) + +if communicator.is_alive(): + communicator.stop() From bbe3999cb59da3af58a3ec041ce9ed940b1b5656 Mon Sep 17 00:00:00 2001 From: Vincent Saluzzo Date: Sun, 21 Oct 2018 15:59:13 +0200 Subject: [PATCH 2/4] add new profile to generated doc --- SUPPORTED_PROFILES.md | 165 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 144 insertions(+), 21 deletions(-) diff --git a/SUPPORTED_PROFILES.md b/SUPPORTED_PROFILES.md index 036a426..5a25637 100644 --- a/SUPPORTED_PROFILES.md +++ b/SUPPORTED_PROFILES.md @@ -35,18 +35,6 @@ All profiles (should) correspond to the official [EEP](http://www.enocean-allian -##### RORG 0xF6 - FUNC 0x05 - TYPE 0x01 - Liquid Leakage Sensor (mechanic harvester) - -|shortcut|description |type |values | -|--------|--------------------------------------------------|--------|---- | -|WAS |Water Sensor |enum |0-16 - not specified | -| | | |17 - Water detected | -| | | |18-255 - not specified | -|T21 |T21 |status | | -|NU |NU |status | | - - - ##### RORG 0xF6 - FUNC 0x10 - TYPE 0x00 - Window Handle |shortcut|description |type |values | @@ -270,6 +258,30 @@ All profiles (should) correspond to the official [EEP](http://www.enocean-allian +##### RORG 0xA5 - FUNC 0x07 - TYPE 0x01 - Occupancy with Supply voltage monitor + +|shortcut|description |type |values | +|--------|--------------------------------------------------|--------|---- | +|SVC |Supply voltage (OPTIONAL) |value |0.0-250.0 ↔ 0.0-5.0 V | +|PIR |PIR Status |enum |0 - off | +| | | |1 - on | + + + +##### RORG 0xA5 - FUNC 0x08 - TYPE 0x01 - Range 0lx to 510lx, 0°C to +51°C and Occupancy Button + +|shortcut|description |type |values | +|--------|--------------------------------------------------|--------|---- | +|SVC |Supply voltage (linear) |value |0.0-255.0 ↔ 0.0-5.1 V | +|ILL |Illumination (linear) |value |0.0-255.0 ↔ 0.0-510.0 lx | +|TMP |Temperature (linear) |value |0.0-255.0 ↔ 0.0-51.0 °C | +|PIRS |PIR Status |enum |0 - PIR on | +| | | |1 - PIR off | +|OCC |Occupancy Button |enum |0 - Button pressed | +| | | |1 - Button released | + + + ##### RORG 0xA5 - FUNC 0x10 - TYPE 0x03 - Temperature Sensor and Set Point |shortcut|description |type |values | @@ -278,6 +290,15 @@ All profiles (should) correspond to the official [EEP](http://www.enocean-allian |TMP |Temperature (linear) |value |255.0-0.0 ↔ 0.0-40.0 °C | +##### RORG 0xA5 - FUNC 0x10 - TYPE 0x12 - Temperature and Humidity Sensor and Set Point + +|shortcut|description |type |values | +|--------|--------------------------------------------------|--------|---- | +|SP |Set Point (linear) |value |0.0-255.0 ↔ 0.0-255.0 | +|HUM |Rel. Humidity (linear) |value |0.0-250.0 ↔ 0.0-100.0 % | +|TMP |Temperature (linear) |value |0.0-250.0 ↔ 0.0-40.0 °C | + + ##### RORG 0xA5 - FUNC 0x11 - TYPE 0x02 - Temperature Controller Output @@ -310,6 +331,16 @@ All profiles (should) correspond to the official [EEP](http://www.enocean-allian +##### RORG 0xA5 - FUNC 0x14 - TYPE 0x01 - Single Input Contact (Window/Door), Supply voltage monitor + +|shortcut|description |type |values | +|--------|--------------------------------------------------|--------|---- | +|SVC |Supply voltage / super cap. (linear); 251 - 255 reserved for error code|value |0.0-250.0 ↔ 0.0-5.0 V | +|CT |Contact |enum |1 - open | +| | | |0 - closed | + + + ##### RORG 0xA5 - FUNC 0x20 - TYPE 0x01 - Battery Powered Actuator (BI-DIR) ###### direction: 1 @@ -373,18 +404,50 @@ All profiles (should) correspond to the official [EEP](http://www.enocean-allian -##### RORG 0xA5 - FUNC 0x12 - TYPE 0x01 - Electricity +##### RORG 0xA5 - FUNC 0x30 - TYPE 0x03 - Digital Inputs, Wake and Temperature |shortcut|description |type |values | |--------|--------------------------------------------------|--------|---- | -|MR |current value in W or cumulative value in kWh |value |0.0-16777215.0 ↔ 0.0-16777215.0 | -|TI |Tariff info |value |0.0-15.0 ↔ 0.0-15.0 | -|DT |Current value or cumulative value |enum |0 - kWh | -| | | |1 - W | -|DIV |Divisor for value |enum |0 - x/1 | -| | | |1 - x/10 | -| | | |2 - x/100 | -| | | |3 - x/1000 | +|TMP |Temperature (linear) |value |255.0-0.0 ↔ 0.0-40.0 °C | +|WA0 |Value of wake signal |enum |0 - Low | +| | | |1 - High | +|DI3 |Digital Input 3 |enum |0 - Low | +| | | |1 - High | +|DI2 |Digital Input 2 |enum |0 - Low | +| | | |1 - High | +|DI1 |Digital Input 1 |enum |0 - Low | +| | | |1 - High | +|DI0 |Digital Input 0 |enum |0 - Low | +| | | |1 - High | + + + +##### RORG 0xA5 - FUNC 0x38 - TYPE 0x08 - Gateway + +###### command: 1 +|shortcut|description |type |values | +|--------|--------------------------------------------------|--------|---- | +|COM |Command ID |enum |0-13 - Command ID {value} | +|TIM |Time in 1/10 seconds. 0 = no time specifed |value |1.0-65535.0 ↔ 0.1-6553.5 s | +|LCK |Lock for duration time if time >0, unlimited time of no time specified. Locking may be cleared with "unlock". During lock phase no other commands will be accepted or executed|enum |0 - Unlock | +| | | |1 - Lock | +|DEL |Delay or duration (if Time > 0); 0 = Duration (Execute switching command immediately and switch back after duration) 1 = Delay (Execute switching command after delay)|enum |0 - Duration | +| | | |1 - Delay | +|SW |Switching command ON/OFF |enum |0 - Off | +| | | |1 - On | + +###### command: 2 +|shortcut|description |type |values | +|--------|--------------------------------------------------|--------|---- | +|COM |Command ID |enum |0-13 - Command ID {value} | +|EDIM |Dimming value (absolute [0...255] or relative [0...100])|value |0.0-255.0 ↔ 0.0-255.0 % | +|RMP |Ramping time in seconds, 0 = no ramping, 1...255 = seconds to 100%|value |0.0-255.0 ↔ 0.0-255.0 s | +|EDIMR |Dimming Range |enum |0 - Absolute value | +| | | |1 - Relative value | +|STR |Store final value |enum |0 - No | +| | | |1 - Yes | +|SW |Switching command |enum |0 - Off | +| | | |1 - On | @@ -434,3 +497,63 @@ All profiles (should) correspond to the official [EEP](http://www.enocean-allian +##### RORG 0xD2 - FUNC 0x05 - TYPE 0x00 - Type 0x00 + +###### command: 1 +|shortcut|description |type |values | +|--------|--------------------------------------------------|--------|---- | +|POS |Vertical position |enum |0-100 - Output position {value}% | +| | | |127 - Do not change | +|ANG |Rotation angle |enum |0-100 - Output angle {value}% | +| | | |127 - Do not change | +|REPO |Repositioning |enum |0 - Go directly to POS/ANG | +| | | |1 - Go up (0%), then to POS/ANG | +| | | |2 - Go down (100%), then to POS/ANG | +| | | |3 - Reserved | +|LOCK |Locking modes |enum |0 - Do not change | +| | | |1 - Set blockage mode | +| | | |2 - Set alarm mode | +| | | |3 - Reserved | +| | | |4 - Reserved | +| | | |5 - Reserved | +| | | |6 - Reserved | +| | | |7 - Deblockage | +|CHN |Channel |enum |0 - Channel 1 | +|CMD |Command Id |enum |0-5 - Command ID {value} | + +###### command: 2 +|shortcut|description |type |values | +|--------|--------------------------------------------------|--------|---- | +|CHN |Channel |enum |0 - Channel 1 | +|CMD |Command Id |enum |0-5 - Command ID {value} | + +###### command: 3 +|shortcut|description |type |values | +|--------|--------------------------------------------------|--------|---- | +|CHN |Channel |enum |0 - Channel 1 | +|CMD |Command Id |enum |0-5 - Command ID {value} | + +###### command: 4 +|shortcut|description |type |values | +|--------|--------------------------------------------------|--------|---- | +|POS |Vertical position |enum |0-100 - Output position {value}% | +| | | |127 - Do not change | +|ANG |Rotation angle |enum |0-100 - Output angle {value}% | +| | | |127 - Do not change | +|REPO |Repositioning |enum |0 - Go directly to POS/ANG | +| | | |1 - Go up (0%), then to POS/ANG | +| | | |2 - Go down (100%), then to POS/ANG | +| | | |3 - Reserved | +|LOCK |Locking modes |enum |0 - Do not change | +| | | |1 - Set blockage mode | +| | | |2 - Set alarm mode | +| | | |3 - Reserved | +| | | |4 - Reserved | +| | | |5 - Reserved | +| | | |6 - Reserved | +| | | |7 - Deblockage | +|CHN |Channel |enum |0 - Channel 1 | +|CMD |Command Id |enum |0-5 - Command ID {value} | + + + From 69ccac1991c2960b6900a213d55233b92ec8d458 Mon Sep 17 00:00:00 2001 From: Vincent Saluzzo Date: Sun, 21 Oct 2018 16:03:59 +0200 Subject: [PATCH 3/4] reput classic tty (not macOS one) --- enocean/communicators/serialcommunicator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enocean/communicators/serialcommunicator.py b/enocean/communicators/serialcommunicator.py index e67e4a5..ffe4201 100644 --- a/enocean/communicators/serialcommunicator.py +++ b/enocean/communicators/serialcommunicator.py @@ -11,7 +11,7 @@ class SerialCommunicator(Communicator): ''' Serial port communicator class for EnOcean radio ''' logger = logging.getLogger('enocean.communicators.SerialCommunicator') - def __init__(self, port='/dev/tty.usbserial-FT1SEG3T', callback=None): + def __init__(self, port='/dev/ttyAMA0', callback=None): super(SerialCommunicator, self).__init__(callback) # Initialize serial port self.__ser = serial.Serial(port, 57600, timeout=0.1) From 146a0ac0be50af79dc2e60c4ce65922d91eda561 Mon Sep 17 00:00:00 2001 From: Vincent Saluzzo Date: Sun, 28 Oct 2018 14:43:53 +0100 Subject: [PATCH 4/4] change lib name (original fork unmaintained by contributor) and replace it to version 1.0.0 --- setup.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 55cc1b7..3db801f 100644 --- a/setup.py +++ b/setup.py @@ -5,12 +5,12 @@ from distutils.core import setup setup( - name='enocean', - version='0.41.0', - description='EnOcean serial protocol implementation', - author='Kimmo Huoman', - author_email='kipenroskaposti@gmail.com', - url='https://github.com/kipe/enocean', + name='enocean-lib', + version='1.0.0', + description='EnOcean serial protocol implementation (forked from enocean python package)', + author='Vincent Saluzzo', + author_email='vincentsaluzzo@gmail.com', + url='https://github.com/vincentsaluzzo/enocean-lib', packages=[ 'enocean', 'enocean.protocol',