Skip to content

Support new xiaomi aqara device model and LAN protocol 2.0#13540

Merged
syssi merged 10 commits intohome-assistant:devfrom
kerwin612:dev
Apr 25, 2018
Merged

Support new xiaomi aqara device model and LAN protocol 2.0#13540
syssi merged 10 commits intohome-assistant:devfrom
kerwin612:dev

Conversation

@kerwin612
Copy link
Copy Markdown
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
Copy Markdown
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!

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

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

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

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)

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

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

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy Markdown
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.

self._sid = device['sid']
self._name = '{}_{}'.format(device_type, self._sid)
self._type = device_type
self._proto = xiaomi_hub.proto
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

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

@Danielhiversen
Copy link
Copy Markdown
Member

Then you should remove self._proto for now.

@syssi
Copy link
Copy Markdown
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

devices.append(XiaomiSensor(device, 'Humidity',
'humidity', gateway))
elif device['model'] == 'weather.v1':
elif device['model'] in ['weather', 'weather.v1']:
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

???

@syssi
Copy link
Copy Markdown
Member

syssi commented Apr 24, 2018

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

@kerwin612
Copy link
Copy Markdown
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