Skip to content

Fixes and enhancements for the Tahoma platform#11547

Merged
pvizeli merged 5 commits into
home-assistant:devfrom
glpatcern:tahoma-pr
Jan 13, 2018
Merged

Fixes and enhancements for the Tahoma platform#11547
pvizeli merged 5 commits into
home-assistant:devfrom
glpatcern:tahoma-pr

Conversation

@glpatcern
Copy link
Copy Markdown
Contributor

Description:

Hi there,

Related to PR #11538, here you find a few more fixes and enhancements. They all work on my installation, will follow up for the automated linting/CI tests.

A breaking change is commit 963b34e that changes the entity IDs in HA. For this, I appreciate some feedback from @philklei as the original author and @bakedraccoon as the contributor of the above-mentioned PR.

Related issue (if applicable):

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

Example entry for configuration.yaml (if applicable):

Checklist:

  • The code change is tested and works locally.

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • 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:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

return 100
return position
try:
position = 100 - self.tahoma_device.active_states['core:ClosureState']
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 (82 > 79 characters)

@thijsdejong
Copy link
Copy Markdown
Contributor

I think stripping off the entity id is a good choice. It's currently incredibly messy since it adds 24+ numbers that are already in 'tahoma_device_id' 👍

eid = eid[:eid.rfind('_rts')]
elif eid.rfind('_io') > 0:
eid = eid[:eid.rfind('_io')]
self.entity_id = eid
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.

Do you realy need to set the entity_id and don't let's auto generate from internal core/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.

The point is that - as mentioned above - the current entity_id looks like <custom_name>_rts_<NNN>, where <NNN> is a very long numeric ID internally used by the TaHoma box to reference the shutters. This makes writing automations pretty unpractical (and the produced code unreadable).

IMHO Home Assistant should abstract from such platform-dependent details and expose high-level identifiers, so I believe it is definitely worth to override the auto-generated identifiers 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.

@pvizeli Currently an entity id look like this: cover.bedroom_middle_io12345678901234567890 . Having cover.bedroom_middle would be more desireable, right?

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. Home-Assistant generate automatic entity_id with name. Remove the entity_id and the core do that automatic. For unique_id, you can only use the NN if they is unique.

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.

So the question is about the pre-existing statement at L36, right? Do I understand correctly that leaving entity_id unassigned will make Home Assistant auto-generate an appropriate name?
There's no question about unique_id including the full identifier.

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.

Answering to my own question: yes. Even better, the patch will be to remove L36 altogether.

@glpatcern
Copy link
Copy Markdown
Contributor Author

This should now be all good, the travis CI failed only because of a timeout.

@thijsdejong
Copy link
Copy Markdown
Contributor

thijsdejong commented Jan 10, 2018

Travis CI is failing because you're importing ENTITY_ID_FORMAT but it's not being used. https://github.com/glpatcern/home-assistant/blob/a061418e9e9037ec2af1004f26d56a7ffb2ed625/homeassistant/components/cover/tahoma.py#L10

As per suggestions, let HA do the standard initialization and assign
an appropriate entity_id, instead of overriding it with the lengthy
unique_id coming from the TaHoma devices.
@glpatcern
Copy link
Copy Markdown
Contributor Author

Good point, sorry to have overlooked it. Being at it, I completely removed the constructor and extended the commit message to explain why we just want to use the default behavior from HA.

@glpatcern
Copy link
Copy Markdown
Contributor Author

And yes, this time no timeouts and no warnings, so should be good to go.

@pvizeli pvizeli merged commit 9d67d22 into home-assistant:dev Jan 13, 2018
@balloob balloob mentioned this pull request Jan 26, 2018
@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
@ghost ghost removed the platform: cover.tahoma 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.

6 participants