1
0
mirror of https://github.com/home-assistant/core.git synced 2025-05-08 16:09:22 +00:00
Poltorak Serguei 3c5a667d97
Add Z-Wave.Me integration ()
* Add support of Z-Wave.Me Z-Way and RaZberry server ()

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: LawfulChaos <kerbalspacema@gmail.com>

* Add switch platform to Z-Wave.Me integration ()

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com>

* Add button platform to Z-Wave.Me integration ()

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Fix button controller access ()

* Add lock platform to Z-Wave.Me integration  ()

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Add sensor platform to Z-Wave.Me integration ()

* Sensor Entity

* Sensor fixes

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Inline descriotion according to review proposal

* State Classes for sensor

* Generic sensor

* Generic sensor

Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Add binary sensor platform to Z-Wave.Me integration ()

* Binary Sensor Entity

* Update docstring

Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Add Light Entity platform to Z-Wave.Me integration ()

* Light Entity

* mypy fix

* Fixes, ZWaveMePlatforms enum

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Fixes

* Fixes

* Fixes

Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Add Thermostat platform to Z-Wave.Me integration  ()

* Climate entity

* Climate entity

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Climate entity fix

* Clean up

* cleanup

* Import order fix

* Correct naming

Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Correct zwave_me .coveragerc ()

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: LawfulChaos <kerbalspacema@gmail.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-02-07 16:27:11 +01:00

68 lines
1.9 KiB
Python

"""Representation of a switchBinary."""
import logging
from typing import Any
from homeassistant.components.switch import (
SwitchDeviceClass,
SwitchEntity,
SwitchEntityDescription,
)
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from . import ZWaveMeEntity
from .const import DOMAIN, ZWaveMePlatform
_LOGGER = logging.getLogger(__name__)
DEVICE_NAME = ZWaveMePlatform.SWITCH
SWITCH_MAP: dict[str, SwitchEntityDescription] = {
"generic": SwitchEntityDescription(
key="generic",
device_class=SwitchDeviceClass.SWITCH,
)
}
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the switch platform."""
@callback
def add_new_device(new_device):
controller = hass.data[DOMAIN][config_entry.entry_id]
switch = ZWaveMeSwitch(controller, new_device, SWITCH_MAP["generic"])
async_add_entities(
[
switch,
]
)
config_entry.async_on_unload(
async_dispatcher_connect(
hass, f"ZWAVE_ME_NEW_{DEVICE_NAME.upper()}", add_new_device
)
)
class ZWaveMeSwitch(ZWaveMeEntity, SwitchEntity):
"""Representation of a ZWaveMe binary switch."""
def __init__(self, controller, device, description):
"""Initialize the device."""
super().__init__(controller, device)
self.entity_description = description
@property
def is_on(self) -> bool:
"""Return the state of the switch."""
return self.device.level == "on"
def turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on."""
self.controller.zwave_api.send_command(self.device.id, "on")
def turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off."""
self.controller.zwave_api.send_command(self.device.id, "off")