Skip to content
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

Merged
merged 10 commits into from
Apr 25, 2018

Conversation

kerwin612
Copy link
Contributor

@kerwin612 kerwin612 commented Mar 30, 2018

Description:

  • Support new device model.
  • Support new LAN protocol 2.0.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@homeassistant
Copy link
Contributor

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',

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',

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']:

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',

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',

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

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

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

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

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)

Copy link
Member

@fabaff fabaff left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

@kerwin612
Copy link
Contributor Author

It is not used currently. I think it may be used later.

@Danielhiversen
Copy link
Member

Then you should remove self._proto for now.

@syssi
Copy link
Member

syssi commented Apr 2, 2018

@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']:
Copy link
Member

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?

Copy link
Contributor Author

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',
Copy link
Member

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?

Copy link
Contributor Author

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

@MartinHjelmare MartinHjelmare changed the title support new device model;support new LAN protocol 2.0 Support new xiaomi aqara device model and LAN protocol 2.0 Apr 2, 2018
@syssi syssi removed the docs-missing label Apr 3, 2018
@kerwin612
Copy link
Contributor Author

???

@syssi
Copy link
Member

syssi commented Apr 24, 2018

@ileler I will merge the PR soon. I just need some more time for testing.

@kerwin612
Copy link
Contributor Author

@syssi Thanks

@syssi syssi merged commit 0a0d34d into home-assistant:dev Apr 25, 2018
@balloob balloob mentioned this pull request May 11, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants