-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Add switch platform for Danfoss Air and additional sensors. #21046
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
74063f4
Add switch platform for Danfoss Air and additional sensors.
JonasPed 05bcfc6
Solve lint issues.
JonasPed f3bbc0f
Correct style.
JonasPed 22be320
Minor changes
fabaff 0d91ecc
Minor changes
fabaff cedfaf0
Minor changes
fabaff e661918
Update file header
fabaff e65a5bb
Remove space
fabaff 07c2dd8
Remove space
fabaff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| """Support for the for Danfoss Air HRV sswitches.""" | ||
| import logging | ||
|
|
||
| from homeassistant.components.switch import ( | ||
| SwitchDevice) | ||
| from homeassistant.components.danfoss_air import DOMAIN \ | ||
| as DANFOSS_AIR_DOMAIN | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def setup_platform(hass, config, add_entities, discovery_info=None): | ||
| """Set up the Danfoss Air HRV switch platform.""" | ||
| from pydanfossair.commands import ReadCommand, UpdateCommand | ||
|
|
||
| data = hass.data[DANFOSS_AIR_DOMAIN] | ||
|
|
||
| switches = [ | ||
| ["Danfoss Air Boost", | ||
| ReadCommand.boost, | ||
| UpdateCommand.boost_activate, | ||
| UpdateCommand.boost_deactivate], | ||
| ] | ||
|
|
||
| dev = [] | ||
|
|
||
| for switch in switches: | ||
| dev.append(DanfossAir( | ||
| data, switch[0], switch[1], switch[2], switch[3])) | ||
|
|
||
| add_entities(dev) | ||
|
|
||
|
|
||
| class DanfossAir(SwitchDevice): | ||
| """Representation of a Danfoss Air HRV Switch.""" | ||
|
|
||
| def __init__(self, data, name, state_command, on_command, off_command): | ||
| """Initialize the switch.""" | ||
| self._data = data | ||
| self._name = name | ||
| self._state_command = state_command | ||
| self._on_command = on_command | ||
| self._off_command = off_command | ||
| self._state = None | ||
|
|
||
| @property | ||
| def name(self): | ||
| """Return the name of the switch.""" | ||
| return self._name | ||
|
|
||
| @property | ||
| def is_on(self): | ||
| """Return true if switch is on.""" | ||
| return self._state | ||
|
|
||
| def turn_on(self, **kwargs): | ||
| """Turn the switch on.""" | ||
| _LOGGER.debug("Turning on switch with command %s", self._on_command) | ||
| self._data.update_state(self._on_command, self._state_command) | ||
|
|
||
| def turn_off(self, **kwargs): | ||
| """Turn the switch off.""" | ||
| _LOGGER.debug("Turning of switch with command %s", self._off_command) | ||
| self._data.update_state(self._off_command, self._state_command) | ||
|
|
||
| def update(self): | ||
| """Update the switch's state.""" | ||
| self._data.update() | ||
|
|
||
| self._state = self._data.get_value(self._state_command) | ||
| if self._state is None: | ||
| _LOGGER.debug("Could not get data for %s", self._state_command) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.