Skip to content

Commit

Permalink
Add EM400-TLD channels
Browse files Browse the repository at this point in the history
  • Loading branch information
aapris committed Jun 13, 2024
1 parent eedb5eb commit 38deea0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion fvhiot/parsers/milesight.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ def parse_milesight(hex_str: str, port: int) -> dict:
elif channel_id == 0x04 and channel_type == 0x00:
data['position'] = 0 if byte_data[i] == 0 else 1

Check failure on line 55 in fvhiot/parsers/milesight.py

View workflow job for this annotation

GitHub Actions / tests (3.11)

Ruff (Q000)

fvhiot/parsers/milesight.py:55:18: Q000 Single quotes found but double quotes preferred

Check failure on line 55 in fvhiot/parsers/milesight.py

View workflow job for this annotation

GitHub Actions / tests (3.12)

Ruff (Q000)

fvhiot/parsers/milesight.py:55:18: Q000 Single quotes found but double quotes preferred
i += 1
# EM400-TLD
elif channel_id == 0x04 and channel_type == 0x82:
data['distance'] = read_uint16_le(byte_data[i:i + 2])

Check failure on line 59 in fvhiot/parsers/milesight.py

View workflow job for this annotation

GitHub Actions / tests (3.11)

Ruff (Q000)

fvhiot/parsers/milesight.py:59:18: Q000 Single quotes found but double quotes preferred

Check failure on line 59 in fvhiot/parsers/milesight.py

View workflow job for this annotation

GitHub Actions / tests (3.12)

Ruff (Q000)

fvhiot/parsers/milesight.py:59:18: Q000 Single quotes found but double quotes preferred
i += 2
elif channel_id == 0x05 and channel_type == 0x00:
data['position'] = 0 if byte_data[i] == 0 else 1

Check failure on line 62 in fvhiot/parsers/milesight.py

View workflow job for this annotation

GitHub Actions / tests (3.11)

Ruff (Q000)

fvhiot/parsers/milesight.py:62:18: Q000 Single quotes found but double quotes preferred

Check failure on line 62 in fvhiot/parsers/milesight.py

View workflow job for this annotation

GitHub Actions / tests (3.12)

Ruff (Q000)

fvhiot/parsers/milesight.py:62:18: Q000 Single quotes found but double quotes preferred
i += 1
elif channel_id == 0x83 and channel_type == 0x67:
data["temperature"] = read_int16_le(byte_data[i: i + 2]) / 10.0
data["temperature_abnormal"] = byte_data[i + 2]
i += 3
elif channel_id == 0x84 and channel_type == 0x82:
data['distance'] = read_uint16_le(byte_data[i:i + 2])

Check failure on line 69 in fvhiot/parsers/milesight.py

View workflow job for this annotation

GitHub Actions / tests (3.11)

Ruff (Q000)

fvhiot/parsers/milesight.py:69:18: Q000 Single quotes found but double quotes preferred

Check failure on line 69 in fvhiot/parsers/milesight.py

View workflow job for this annotation

GitHub Actions / tests (3.12)

Ruff (Q000)

fvhiot/parsers/milesight.py:69:18: Q000 Single quotes found but double quotes preferred
data['distance_alarming'] = byte_data[i + 2]

Check failure on line 70 in fvhiot/parsers/milesight.py

View workflow job for this annotation

GitHub Actions / tests (3.11)

Ruff (Q000)

fvhiot/parsers/milesight.py:70:18: Q000 Single quotes found but double quotes preferred

Check failure on line 70 in fvhiot/parsers/milesight.py

View workflow job for this annotation

GitHub Actions / tests (3.12)

Ruff (Q000)

fvhiot/parsers/milesight.py:70:18: Q000 Single quotes found but double quotes preferred
i += 3
elif channel_id == 0x20 and channel_type == 0xCE:
point = {
"timestamp": read_uint32_le(byte_data[i: i + 4]),
Expand Down Expand Up @@ -121,6 +136,9 @@ def main(samples: list):
["0367ed0004684b", 85],
["0367f100046847", 85],
["0175640367f500046866", 85],
["01755C03824408040000", 85], # "battery": 92, "distance": 2116, "position": 0
["01755C03824408040000", 85], # {"battery": 92, "distance": 2116, "position": 0}
["01755C0367010104824408050001", 85], # {"battery":92,"temperature":25.7,"distance":2116,"position":1}
["8367e800018482410601", 85],
# --> {"temperature": 23.2, "temperature_abnormal": 1, "distance": 1601, "distance_alarming": 1}
]
main(examples)

0 comments on commit 38deea0

Please sign in to comment.