2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Volvo heater."""
|
2017-02-19 01:09:25 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from homeassistant.helpers.entity import ToggleEntity
|
|
|
|
|
2019-03-21 05:56:46 +00:00
|
|
|
from . import DATA_KEY, VolvoEntity
|
|
|
|
|
2017-02-19 01:09:25 +00:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
2018-10-05 05:48:40 +00:00
|
|
|
"""Set up a Volvo switch."""
|
2017-02-19 01:09:25 +00:00
|
|
|
if discovery_info is None:
|
|
|
|
return
|
2018-11-30 18:07:42 +00:00
|
|
|
async_add_entities([VolvoSwitch(hass.data[DATA_KEY], *discovery_info)])
|
2017-02-19 01:09:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class VolvoSwitch(VolvoEntity, ToggleEntity):
|
|
|
|
"""Representation of a Volvo switch."""
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_on(self):
|
|
|
|
"""Return true if switch is on."""
|
2018-11-30 18:07:42 +00:00
|
|
|
return self.instrument.state
|
2017-02-19 01:09:25 +00:00
|
|
|
|
2018-11-30 18:07:42 +00:00
|
|
|
async def async_turn_on(self, **kwargs):
|
2017-02-19 01:09:25 +00:00
|
|
|
"""Turn the switch on."""
|
2018-11-30 18:07:42 +00:00
|
|
|
await self.instrument.turn_on()
|
2017-02-19 01:09:25 +00:00
|
|
|
|
2018-11-30 18:07:42 +00:00
|
|
|
async def async_turn_off(self, **kwargs):
|
2017-02-19 01:09:25 +00:00
|
|
|
"""Turn the switch off."""
|
2018-11-30 18:07:42 +00:00
|
|
|
await self.instrument.turn_off()
|