Skip to content

Commit

Permalink
Merge pull request #844 from CaeruleusAqua/Knx_dpt_5.003
Browse files Browse the repository at this point in the history
knx: Add dpt 5003
  • Loading branch information
msinn authored Nov 3, 2023
2 parents 5c1fe33 + e6b223f commit 9396d51
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
16 changes: 15 additions & 1 deletion knx/dpts.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ def de5001(payload):
return round(struct.unpack('>B', payload)[0] * 100.0 / 255, 1)


def en5003(value):
value = value % 360
return [0, int(value * 255.0 / 360) & 0xff]


def de5003(payload):
if len(payload) != 1:
return None
return round(struct.unpack('>B', payload)[0] * 360.0 / 255, 1)


def en5999(value):
# artificial data point for tebis TS systems
if value < 0:
Expand Down Expand Up @@ -545,6 +556,8 @@ def dega(string):
'5': de5,
'5001': de5001,
'5.001': de5001,
'5003': de5003, #DPT_Angle [0..360] °
'5.003': de5003, #DPT_Angle [0..360] °
'5999': de5999,
'5.999': de5999,
'6': de6,
Expand Down Expand Up @@ -591,7 +604,8 @@ def dega(string):
'5': en5, #One Byte: unsigned value
'5001': en5001, #DPT_Scaling [0 ... 100] %
'5.001': en5001, #DPT_Scaling [0 ... 100] %
# 5.003 -> DPT_Angle [0..360] °
'5003': en5003, #DPT_Angle [0..360] °
'5.003': en5003, #DPT_Angle [0..360] °
# 5.004 -> DPT_Percent_U8 [0..255] %
# 5.005 -> DPT_DecimalFactor
'5999': en5999, #artificial data point for tebis TS systems
Expand Down
12 changes: 12 additions & 0 deletions knx/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ item_attributes:
- '5'
- '5001'
- '5.001'
- '5003'
- '5.003'
- '5999'
- '5.999'
- '6'
Expand Down Expand Up @@ -210,6 +212,8 @@ item_attributes:
- 'Relativwert, 0 … 255 (8 Bit) -> num'
- 'Relativwert, 0 … 100 % (8 Bit) -> num'
- 'Relativwert, 0 … 100 % (8 Bit) -> num'
- 'Winkel, 0 … 360 ° (8 Bit) -> num'
- 'Winkel, 0 … 360 ° (8 Bit) -> num'
- 'Spezial DPT für Tebis TS Systeme, (8 Bit) -> num'
- 'Spezial DPT für Tebis TS Systeme, (8 Bit) -> num'
- 'Ganzzahl -128 - 127 (8 Bit) -> num'
Expand Down Expand Up @@ -246,6 +250,8 @@ item_attributes:
- 'Relative value, 0 … 255 (8 Bit) -> num'
- 'Relative value, 0 … 100 % (8 Bit) -> num'
- 'Relative value, 0 … 100 % (8 Bit) -> num'
- 'Angle value, 0 … 360 ° (8 Bit) -> num'
- 'Angle value, 0 … 360 ° (8 Bit) -> num'
- 'Special DPT for Tebis TS systems, (8 Bit) -> num'
- 'Special DPT for Tebis TS systems, (8 Bit) -> num'
- 'Integer -128 - 127 (8 Bit) -> num'
Expand Down Expand Up @@ -385,6 +391,8 @@ plugin_functions:
- '5'
- '5001'
- '5.001'
- '5003'
- '5.003'
- '5999'
- '5.999'
- '6'
Expand Down Expand Up @@ -421,6 +429,8 @@ plugin_functions:
- 'Relativwert, 0 … 255 (8 Bit) -> num'
- 'Relativwert, 0 … 100 % (8 Bit) -> num'
- 'Relativwert, 0 … 100 % (8 Bit) -> num'
- 'Winkel, 0 … 360 ° (8 Bit) -> num'
- 'Winkel, 0 … 360 ° (8 Bit) -> num'
- 'Spezial DPT für Tebis TS Systeme, (8 Bit) -> num'
- 'Spezial DPT für Tebis TS Systeme, (8 Bit) -> num'
- 'Ganzzahl -128 - 127 (8 Bit) -> num'
Expand Down Expand Up @@ -456,6 +466,8 @@ plugin_functions:
- 'Relative value, 0 … 255 (8 Bit) -> num'
- 'Relative value, 0 … 100 % (8 Bit) -> num'
- 'Relative value, 0 … 100 % (8 Bit) -> num'
- 'Angle value, 0 … 360 ° (8 Bit) -> num'
- 'Angle value, 0 … 360 ° (8 Bit) -> num'
- 'Special DPT for Tebis TS systems, (8 Bit) -> num'
- 'Special DPT for Tebis TS systems, (8 Bit) -> num'
- 'Integer -128 - 127 (8 Bit) -> num'
Expand Down

0 comments on commit 9396d51

Please sign in to comment.