Skip to content

Add Nest away binary sensor and eta sensor#14406

Merged
syssi merged 6 commits intohome-assistant:devfrom
awarecan:nest-away-sensor
May 23, 2018
Merged

Add Nest away binary sensor and eta sensor#14406
syssi merged 6 commits intohome-assistant:devfrom
awarecan:nest-away-sensor

Conversation

@awarecan
Copy link
Copy Markdown
Contributor

@awarecan awarecan commented May 12, 2018

Description:

away and eta_begin are two data already in Nest structure data, but didn't exposed in HA for some reason. However, HA provide a service to change away mode, that is strange for me. So I want to expose those attribute to HA.

Related issue (if applicable): fixes #

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

Example entry for configuration.yaml (if applicable):

Auto discover/configuration sensors, no change on configuration

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:

awarecan added 4 commits May 11, 2018 20:34
Comment out one line of code for security_state which need future version of python-nest
Comment out one line of code for security_state which need future version of python-nest
@dgomes
Copy link
Copy Markdown
Contributor

dgomes commented May 23, 2018

If there are 2 features, you should create 2 separate PR's

EDIT: the PR is small enough to be reviewed together, so ignore this comment, take the comment in for future PR's only

dgomes
dgomes previously requested changes May 23, 2018
# device specific
self.device = device
self._location = self.device.where
self._name = "{} {}".format(self.device.name_long,
Copy link
Copy Markdown
Contributor

@dgomes dgomes May 23, 2018

Choose a reason for hiding this comment

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

from homeassistant.util import slugify

better then using custom format

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.

slugify is doing replace(" ", "_"), but I am doing replace("_", " ") here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ups, you are right 👍

else:
# structure only
self.device = structure
self._name = "{} {}".format(self.structure.name,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

slugify

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.

logic here is reverse version of slugify, but I will change "_" to single quote

@awarecan
Copy link
Copy Markdown
Contributor Author

@dgomes They are all from Nest's structure data, one is binary sensor, and another is sensor. Do I need to split them to separate PR?

Comment thread homeassistant/components/nest.py Outdated
@@ -190,8 +203,8 @@ def smoke_co_alarms(self):
for device in structure.smoke_co_alarms:
yield(structure, device)
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.

Add one whitespace after yield

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.

done

Comment thread homeassistant/components/nest.py Outdated
@@ -204,8 +217,8 @@ def cameras(self):
for device in structure.cameras:
yield(structure, device)
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.

Add one whitespace after yield

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.

done

Comment thread homeassistant/components/sensor/nest.py Outdated
if self.variable == 'operation_mode':
self._state = getattr(self.device, "mode")
elif self.variable == 'eta':
self._state = getattr(self.device, 'eta_begin')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know that you are just following the existing code, but maybe these string should be moved to constants

at least harmonize the use of ' and "

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.

Yes, a dictionary should be used here:

SENSOR_VARS = {'operation_mode': 'mode',
               'eta': 'eta_begin'}

Copy link
Copy Markdown
Contributor Author

@awarecan awarecan May 23, 2018

Choose a reason for hiding this comment

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

I will change if/elif to if self.variable in VARIABLE_NAME_MAPPING:

@dale3h
Copy link
Copy Markdown
Member

dale3h commented May 23, 2018

@awarecan Please do not split this into two PRs. We are going to leave it as one single PR since it is already open, and because the two sensors rely on the same change(s) to the core component.

@dale3h dale3h dismissed dgomes’s stale review May 23, 2018 18:25

Changes do not apply

@dale3h
Copy link
Copy Markdown
Member

dale3h commented May 23, 2018

This seems ready to merge. Does anyone else have any changes to request?

Copy link
Copy Markdown
Member

@syssi syssi left a comment

Choose a reason for hiding this comment

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

LGTM

@dgomes
Copy link
Copy Markdown
Contributor

dgomes commented May 23, 2018

LGTM

@syssi syssi merged commit 3498234 into home-assistant:dev May 23, 2018
@awarecan awarecan deleted the nest-away-sensor branch May 24, 2018 02:19
@balloob balloob mentioned this pull request Jun 8, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Sep 5, 2018
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.

5 participants