-
-
Notifications
You must be signed in to change notification settings - Fork 275
Add michelin tms #1522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Gr3G63
wants to merge
7
commits into
custom-components:master
Choose a base branch
from
Gr3G63:add_michelin_tms
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add michelin tms #1522
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
60fbede
Add TMS Michelin
gregorymenadier 897af47
Add TMS Michelin
gregorymenadier 6a65287
Add TMS Michelin
gregorymenadier 23334d8
Add TMS Michelin
gregorymenadier b6733d8
Merge branch 'custom-components:master' into add_michelin_tms
Gr3G63 e8f2f8f
Add TMS Michelin
gregorymenadier 03d7802
Adding support of TMS Michelin
gregorymenadier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| """Parser for Michelin TMS BLE advertisements.""" | ||
| import logging | ||
| from struct import unpack | ||
|
|
||
| from .helpers import to_mac, to_unformatted_mac | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| def parse_michelin_tms(self, data: bytes, mac: bytes): | ||
| """Parser for Michelin TMS.""" | ||
| msg_length = len(data) | ||
| device_type = "TMS" | ||
| result = {"type": device_type} | ||
| frame_type = data[5] | ||
|
|
||
| if frame_type in [0x03, 0x04]: | ||
| if msg_length != 14: | ||
| _LOGGER.error("Found %s bytes from sensor: %s", msg_length, to_mac(mac)) | ||
| return | ||
| (raw_temp, raw_volt, absolute_pressure_bar, tyre_id, steps, frame_counter) = unpack( | ||
| "<BBH3sBL", data[6:18] | ||
| ) | ||
| temperature_celcius = raw_temp - 60 | ||
| battery_voltage = round((raw_volt / 100) + 1.0, 2) | ||
| result.update({ | ||
| "temperature": temperature_celcius, | ||
| "voltage": battery_voltage, | ||
| "pressure": absolute_pressure_bar, | ||
| "count": frame_counter, | ||
| "steps": steps, | ||
| "text": tyre_id, | ||
| }) | ||
|
|
||
| else: | ||
| _LOGGER.info( | ||
| "BLE ADV from UNKNOWN TMS DEVICE: MAC: %s, ADV: %s", | ||
| to_mac(mac), | ||
| data.hex() | ||
| ) | ||
| return None | ||
|
|
||
| result.update({ | ||
| "mac": to_unformatted_mac(mac), | ||
| "firmware": "TMS", | ||
| "type": device_type, | ||
| "packet": "no packet id", | ||
| "data": True | ||
| }) | ||
| return result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2204,6 +2204,7 @@ class BLEMonitorBinarySensorEntityDescription( | |||||
| 'ST10' : [["temperature", "battery", "rssi"], [], []], | ||||||
| 'MS1' : [["temperature", "battery", "rssi"], [], []], | ||||||
| 'MS2' : [["temperature", "humidity", "battery", "rssi"], [], []], | ||||||
| 'TMS' : [["temperature", "voltage", "pressure", "count", "steps", "text", "rssi"], [], []], | ||||||
| 'S-MATE' : [["rssi"], ["three btn switch left", "three btn switch middle", "three btn switch right"], []], | ||||||
| 'R5' : [["rssi"], ["six btn switch top left", "six btn switch top middle", "six btn switch top right", "six btn switch bottom left", "six btn switch bottom middle", "six btn switch bottom right"], []], | ||||||
| } | ||||||
|
|
@@ -2354,6 +2355,7 @@ class BLEMonitorBinarySensorEntityDescription( | |||||
| 'ST10' : 'MOCREO', | ||||||
| 'MS1' : 'MOCREO', | ||||||
| 'MS2' : 'MOCREO', | ||||||
| 'TMS' : 'MICHELIN', | ||||||
| 'S-MATE' : 'Sonoff', | ||||||
| 'R5' : 'Sonoff', | ||||||
| } | ||||||
|
|
@@ -2439,6 +2441,7 @@ class BLEMonitorBinarySensorEntityDescription( | |||||
| 'XMOSB01XS' : 'Xiaomi', | ||||||
| 'RS1BB' : 'Linptech', | ||||||
| 'ES3' : 'Linptech', | ||||||
| 'TMS' : 'MICHELIN', | ||||||
|
||||||
| 'TMS' : 'MICHELIN', | |
| 'TMS' : 'Michelin', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| """The tests for the Michelin TMS ble_parser.""" | ||
| from ble_monitor.ble_parser import BleParser | ||
|
|
||
|
|
||
| class TestMichelin: | ||
| """Tests for the Michelin TMS parser""" | ||
| def test_parse_michelin_tms(self): | ||
| data_string = "043E2002010000332211A703BC1B02010611FF2808010351C6C00350345301C6000000D1" | ||
| data = bytes(bytearray.fromhex(data_string)) | ||
|
|
||
| # pylint: disable=unused-variable | ||
| ble_parser = BleParser() | ||
| sensor_msg, tracker_msg = ble_parser.parse_raw_data(data) | ||
|
|
||
| assert sensor_msg["firmware"] == "TMS" | ||
| assert sensor_msg["type"] == "TMS" | ||
| assert sensor_msg["mac"] == "BC03A7112233" | ||
| assert sensor_msg["packet"] == "no packet id" | ||
| assert sensor_msg["data"] == True | ||
| assert sensor_msg["temperature"] == 22 | ||
| assert sensor_msg["voltage"] == 2.98 | ||
| assert sensor_msg["pressure"] == 960 | ||
| assert sensor_msg["count"] == 198 | ||
| assert sensor_msg["steps"] == 1 | ||
| assert sensor_msg["text"] == "P4S" | ||
| assert sensor_msg["rssi"] == -47 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| manufacturer: MFP Michelin | ||
| name: "TMS" | ||
| model: TMS | ||
| image: "Michelin_TMS_AL.jpg" | ||
| physical_description: "Round body, no screen" | ||
| broadcasted_properties: | ||
| - temperature | ||
| - absolute pressure | ||
| - battery | ||
| - tire ID | ||
| - step (internal FSM) | ||
| - count (number of transmitted frames) | ||
| - rssi | ||
| broadcasted_property_notes: | ||
| broadcast_rate: | ||
| active_scan: | ||
| encryption_key: | ||
| custom_firmware: | ||
| notes: | ||
| - Sold under TMS AF, AL and AQ | ||
| --- |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.