-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working services to sitch wifi and wifree
- Loading branch information
1 parent
6832912
commit e4b6c9f
Showing
3 changed files
with
141 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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 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,42 @@ | ||
"""Support for Wifi switches""" | ||
import logging | ||
|
||
from homeassistant.helpers.entity import ToggleEntity | ||
from homeassistant.const import CONF_USERNAME | ||
|
||
from .const import DOMAIN | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): | ||
"""Old way.""" | ||
|
||
|
||
async def async_setup_entry(hass, config_entry, async_add_entities): | ||
|
||
switches = [] | ||
account = config_entry.data.get(CONF_USERNAME) | ||
audiData = hass.data[DOMAIN][account] | ||
|
||
switch = ComponentSwitch() | ||
switches.append(switch) | ||
|
||
async_add_entities(switches) | ||
|
||
|
||
class ComponentSwitch(): | ||
"""Representation of a Audi switch.""" | ||
|
||
@property | ||
def is_on(self): | ||
"""Return true if switch is on.""" | ||
return self._instrument.state | ||
|
||
async def async_turn_on(self, **kwargs): | ||
"""Turn the switch on.""" | ||
await self._instrument.turn_on() | ||
|
||
async def async_turn_off(self, **kwargs): | ||
"""Turn the switch off.""" | ||
await self._instrument.turn_off() |
This file contains 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