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

Fibaro components #18487

Merged
merged 5 commits into from Nov 21, 2018

Conversation

@pbalogh77
Contributor

pbalogh77 commented Nov 15, 2018

Description:

Adds cover, light, sensor and switch support to the Fibaro component

Related issue (if applicable): fixes #

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

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.
Added Fibaro omcponents
Added cover, light, sensor and switch components
Show resolved Hide resolved homeassistant/components/cover/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/cover/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/cover/fibaro.py
Show resolved Hide resolved homeassistant/components/cover/fibaro.py
Show resolved Hide resolved homeassistant/components/cover/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/fibaro.py
Show resolved Hide resolved homeassistant/components/switch/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/switch/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/switch/fibaro.py Outdated
Improvements based on code review
Improvements based on code review

@wafflebot wafflebot bot added the in progress label Nov 16, 2018

@amelchio

This comment has been minimized.

Member

amelchio commented Nov 17, 2018

Just a note, it is probably better to create individual PRs for each of the platforms. That way smaller parts can get approved and merged faster without a single person having to read, understand and approve all of it.

That said, I think you should keep this PR now as it is not huge and review has already started.

@pbalogh77

This comment has been minimized.

Contributor

pbalogh77 commented Nov 18, 2018

Thanks Anders, I understand. My thining process was that it might be less work per PR for a reviewer, but overall, it'll take more effort to review it split into 4 PRs. I felt that at this total lines it might be more efficient to go in PR, knowing full well, that this might be discouraging some reviewers, but hoping to reduce the total effort needed. In the future I'll try to cut it into even smaller pieces.

@pbalogh77 pbalogh77 closed this Nov 18, 2018

@wafflebot wafflebot bot removed the in progress label Nov 18, 2018

@pbalogh77 pbalogh77 reopened this Nov 18, 2018

@wafflebot wafflebot bot added the in progress label Nov 18, 2018

@pbalogh77

This comment has been minimized.

Contributor

pbalogh77 commented Nov 18, 2018

Ooops, clicked the wrong button when commenting :-( and I accidentally closed it...

@amelchio

Looks mostly good.

The thresholds in the light platform seem strange and complicate things. Is there some hardware reason that these are needed?

Show resolved Hide resolved homeassistant/components/cover/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/cover/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/cover/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/light/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/light/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/light/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/light/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/fibaro.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/fibaro.py Outdated
@andre-richter

This comment has been minimized.

andre-richter commented Nov 19, 2018

Hi @pbalogh77,

I am using quite a lot of the Fibaro roller shutters and switches with HA, but I am still quite uneducated about HA source code.
Could you explain to me what your PR will change with regards to the status quo? I think I see blind tilt support. Also refactoring to some new HA code base?

Thanks a lot for your efforts!

Andre

@pbalogh77

This comment has been minimized.

Contributor

pbalogh77 commented Nov 19, 2018

Hi @pbalogh77,

I am using quite a lot of the Fibaro roller shutters and switches with HA, but I am still quite uneducated about HA source code.
Could you explain to me what your PR will change with regards to the status quo? I think I see blind tilt support. Also refactoring to some new HA code base?

Thanks a lot for your efforts!

Andre

Hi Andre,

It adds support for Fibaro Home Center hubs, so instead of connecting the Z-wave devices to your HA with a Z-wave stick, you can now use the Fibaro hub and integrate that. The reason for this is that while HA is great, Fibaro HC2 is rock solid and has some features specific to it. I also believe that HA is best at integrating hubs, e.g. not taking over the responsibility of everything, just combining functionality on a higher level. Also, this way I can have the fibaro app as a fall-back if HA stops or crashes to still get into my home :-) In this way, I think HA can be used as a alternative UI for Fibaro hub users too.

Cheers,
Peter

Fixes based on code review
Fixes based on code review
@andre-richter

This comment has been minimized.

andre-richter commented Nov 19, 2018

Hi @pbalogh77,
I am using quite a lot of the Fibaro roller shutters and switches with HA, but I am still quite uneducated about HA source code.
Could you explain to me what your PR will change with regards to the status quo? I think I see blind tilt support. Also refactoring to some new HA code base?
Thanks a lot for your efforts!
Andre

Hi Andre,

It adds support for Fibaro Home Center hubs, so instead of connecting the Z-wave devices to your HA with a Z-wave stick, you can now use the Fibaro hub and integrate that. The reason for this is that while HA is great, Fibaro HC2 is rock solid and has some features specific to it. I also believe that HA is best at integrating hubs, e.g. not taking over the responsibility of everything, just combining functionality on a higher level. Also, this way I can have the fibaro app as a fall-back if HA stops or crashes to still get into my home :-) In this way, I think HA can be used as a alternative UI for Fibaro hub users too.

Cheers,
Peter

Ah, understand! I am using HA without the Fibaro home center so far, and it works quite well. I will keep this in mind though.

Thanks!

Changes to light behavior based on code review
Changes to light behavior based on code review

@frenck frenck added the docs-missing label Nov 19, 2018

Internal changes
Changed how brightness is represented internally.
It should have no impact on functionality.
@amelchio

This comment has been minimized.

Member

amelchio commented Nov 20, 2018

Let's merge this (when the build passes) so the new Fibaro component is complete when it gets released. @pbalogh77 has promised in chat to add documentation soon.

def turn_on(self, **kwargs):
"""Turn the light on."""
with self._update_lock:

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Nov 21, 2018

Member

This could block threads in the thread pool. That's not allowed. A non blocking acquire could work. What are we trying to protect?

This comment has been minimized.

@pbalogh77

pbalogh77 Nov 21, 2018

Contributor

The issue I'm trying to solve is that while we're still executing the turn_on command, another thread is receiving notifications from the fibaro hub and processing them, e.g. there can be calls to the update function. Which can mess up the data a bit and cause some havoc. This is especially troubling in the case of a turned off colored light, which has to issue two consecutive rest api calls to the fibaro hub, both of them resulting one or multiple status updates from the fibaro hub. Since neither function has infinite loops and only of them has actual IO, I don't see how it could lock up a thread permanently, but I'm very open to other ideas of solving this race condition.

This comment has been minimized.

@amelchio

amelchio Nov 21, 2018

Member

The race is real, I had the same issue with LIFX. I am not sure how to best solve it for a threaded platform. As is, I guess it could get ugly if the hub gets unavailable.

This comment has been minimized.

@balloob

balloob Nov 21, 2018

Member

So this should become async_turn_on and Fibaro needs to maintain an async lock. We can't solve this on the Home Assistant level as we don't know exactly how the resources need to be treated that need locking (is it per device, per hub etc).

@amelchio

This comment has been minimized.

Member

amelchio commented Nov 21, 2018

I’ll do a judgement call and merge this so it makes the beta along with the remaining Fibaro news.

I am confident that @pbalogh77 is willing to address the concern that Martin raised in a separate PR, in time for the final release.

@amelchio amelchio merged commit 3b53003 into home-assistant:dev Nov 21, 2018

4 of 5 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
coverage/coveralls Coverage decreased (-0.02%) to 93.03%
Details

@wafflebot wafflebot bot removed the in progress label Nov 21, 2018

mxworm added a commit to mxworm/home-assistant that referenced this pull request Nov 21, 2018

Merge branch 'dev' of https://github.com/home-assistant/home-assistant
…into dev

* 'dev' of https://github.com/home-assistant/home-assistant:
  Fibaro components (home-assistant#18487)
  Change channel with play_media instead of select_source (home-assistant#18474)
  Add cloud pref for Google unlock (home-assistant#18600)
  Update Z-Wave Tests asyncio/yield from -> async/await (home-assistant#18599)
@balloob

This comment has been minimized.

Member

balloob commented Nov 21, 2018

Good call 👍

@balloob

This comment has been minimized.

Member

balloob commented Nov 21, 2018

I am stoked. I think that Fibaro has done a great job building a stable Z-Wave platform, with support for their hub, we will be accessible to a new group of people.

@pbalogh77 pbalogh77 deleted the pbalogh77:fibarodev branch Nov 23, 2018

@balloob balloob referenced this pull request Nov 29, 2018

Merged

0.83 #18776

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment