-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
Support new xiaomi aqara device model and LAN protocol 2.0 #13540
Conversation
Hi @ileler, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
@@ -26,7 +26,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): | |||
for device in gateway.devices['switch']: | |||
model = device['model'] | |||
if model == 'plug': | |||
devices.append(XiaomiGenericSwitch(device, "Plug", 'status', | |||
devices.append(XiaomiGenericSwitch(device, "Plug", 'status' if int(device['proto'][0:1]) == 1 else 'channel_0', |
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.
line too long (127 > 79 characters)
elif model in ['switch', 'sensor_switch.aq2', 'sensor_switch.aq3']: | ||
devices.append(XiaomiButton(device, 'Switch', 'status', | ||
elif model in ['switch', 'sensor_switch', 'sensor_switch.aq2', 'sensor_switch.aq3']: | ||
devices.append(XiaomiButton(device, 'Switch', 'status' if int(device['proto'][0:1]) == 1 else 'channel_0', |
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.
line too long (122 > 79 characters)
devices.append(XiaomiNatgasSensor(device, gateway)) | ||
elif model in ['switch', 'sensor_switch.aq2', 'sensor_switch.aq3']: | ||
devices.append(XiaomiButton(device, 'Switch', 'status', | ||
elif model in ['switch', 'sensor_switch', 'sensor_switch.aq2', 'sensor_switch.aq3']: |
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.
line too long (96 > 79 characters)
@@ -26,7 +26,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): | |||
for device in gateway.devices['switch']: | |||
model = device['model'] | |||
if model == 'plug': | |||
devices.append(XiaomiGenericSwitch(device, "Plug", 'status', | |||
devices.append(XiaomiGenericSwitch(device, "Plug", | |||
'status' if int(device['proto'][0:1]) == 1 else 'channel_0', |
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.
continuation line under-indented for visual indent
line too long (83 > 79 characters)
elif model in ['switch', 'sensor_switch', | ||
'sensor_switch.aq2', 'sensor_switch.aq3']: | ||
devices.append(XiaomiButton(device, 'Switch', | ||
'status' if int(device['proto'][0:1]) == 1 else 'channel_0', |
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.
continuation line under-indented for visual indent
line too long (84 > 79 characters)
devices.append(XiaomiGenericSwitch(device, "Plug", 'status', | ||
devices.append(XiaomiGenericSwitch(device, "Plug", | ||
'status' if 'proto' not in device | ||
or int(device['proto'][0:1]) == 1 |
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.
continuation line under-indented for visual indent
'sensor_switch.aq2', 'sensor_switch.aq3']: | ||
devices.append(XiaomiButton(device, 'Switch', | ||
'status' if 'proto' not in device | ||
or int(device['proto'][0:1]) == 1 |
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.
continuation line under-indented for visual indent
@@ -26,7 +26,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None): | |||
for device in gateway.devices['switch']: | |||
model = device['model'] | |||
if model == 'plug': | |||
devices.append(XiaomiGenericSwitch(device, "Plug", 'status', | |||
devices.append(XiaomiGenericSwitch(device, "Plug", | |||
'status' if 'proto' not in device or int(device['proto'][0:1]) == 1 |
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.
continuation line under-indented for visual indent
line too long (87 > 79 characters)
elif model in ['switch', 'sensor_switch', | ||
'sensor_switch.aq2', 'sensor_switch.aq3']: | ||
devices.append(XiaomiButton(device, 'Switch', | ||
'status' if 'proto' not in device or int(device['proto'][0:1]) == 1 |
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.
continuation line under-indented for visual indent
line too long (87 > 79 characters)
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.
Don't change the permission of the files. They don't need to be executable.
@@ -211,6 +211,7 @@ def __init__(self, device, device_type, xiaomi_hub): | |||
self._sid = device['sid'] | |||
self._name = '{}_{}'.format(device_type, self._sid) | |||
self._type = device_type | |||
self._proto = xiaomi_hub.proto |
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.
Where is this used?
It is not used currently. I think it may be used later. |
Then you should remove |
@ileler I added some docs to support your PR. Please feel free to copy & extend: home-assistant/home-assistant.io#5083 |
@@ -26,7 +26,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): | |||
'temperature', gateway)) | |||
devices.append(XiaomiSensor(device, 'Humidity', | |||
'humidity', gateway)) | |||
elif device['model'] == 'weather.v1': | |||
elif device['model'] in ['weather', 'weather.v1']: |
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.
Are you sure about this ("weather") model name?
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.
yes ,i sure
devices.append(XiaomiNatgasSensor(device, gateway)) | ||
elif model in ['switch', 'sensor_switch.aq2', 'sensor_switch.aq3']: | ||
devices.append(XiaomiButton(device, 'Switch', 'status', | ||
elif model in ['switch', 'sensor_switch', |
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.
Is my assumption correct: The device "switch" is called "sensor_switch" in future (new protocol version). It isn't a new hardware version of the device?
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.
According to me, the sub-device receives a new gateway (protocol 2.0) and the model changes. So, in order to be compatible with the old and new agreements
??? |
@ileler I will merge the PR soon. I just need some more time for testing. |
@syssi Thanks |
Description:
Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: