Skip to content

Add Tuya climate platform#15500

Merged
MartinHjelmare merged 3 commits intohome-assistant:devfrom
huangyupeng:tuya_climate
Jul 17, 2018
Merged

Add Tuya climate platform#15500
MartinHjelmare merged 3 commits intohome-assistant:devfrom
huangyupeng:tuya_climate

Conversation

@huangyupeng
Copy link
Copy Markdown
Contributor

@huangyupeng huangyupeng commented Jul 17, 2018

Description:

Add support for Tuya climate devices. After configuring username and password and country code in Tuya component, home assistant can discover supported devices which related to user's Tuya account and control them through Tuya cloud service.
Now, air conditioner and heater is supported.

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5806

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 or updated 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.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good. A couple of comments.

modes = self.tuya.operation_list()
operation_list = []
for mode in modes:
operation_list.append(TUYA_STATE_TO_HA.get(mode))
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.

We should check for None value before appending the value to the operation list.

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 it expected that the operation list changes during the entity lifetime? Otherwise we could move the creation of the operation list to async_added_to_hass, to not have to do that every state update.

def set_temperature(self, **kwargs):
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
self.tuya.set_temperature(temperature)
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare Jul 17, 2018

Choose a reason for hiding this comment

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

Probably guard for None value before setting the temperature. The temperature argument is optional in the service schema for this method.


async def async_added_to_hass(self):
"""Create operation list when add to hass."""
super().async_added_to_hass()
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.

This is a coroutine so it needs to be awaited.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Nice!

@MartinHjelmare MartinHjelmare merged commit 9292d92 into home-assistant:dev Jul 17, 2018
@ghost ghost removed the in progress label Jul 17, 2018
michaeldavie pushed a commit to michaeldavie/home-assistant that referenced this pull request Jul 31, 2018
* Add Tuya climate platform

* fix as review required

* fix as review required
@balloob balloob mentioned this pull request Aug 3, 2018
girlpunk pushed a commit to girlpunk/home-assistant that referenced this pull request Sep 4, 2018
* Add Tuya climate platform

* fix as review required

* fix as review required
@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018
@ghost ghost removed the platform: climate.tuya label Mar 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants