mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
parent
3daecc7a31
commit
111ffdd77e
@ -19,6 +19,8 @@ from .const import DOMAIN
|
|||||||
from .coordinator import MicroBeesUpdateCoordinator
|
from .coordinator import MicroBeesUpdateCoordinator
|
||||||
from .entity import MicroBeesEntity
|
from .entity import MicroBeesEntity
|
||||||
|
|
||||||
|
COVER_IDS = {47: "roller_shutter"}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
@ -32,11 +34,17 @@ async def async_setup_entry(
|
|||||||
MBCover(
|
MBCover(
|
||||||
coordinator,
|
coordinator,
|
||||||
bee_id,
|
bee_id,
|
||||||
next(filter(lambda x: x.deviceID == 551, bee.actuators)).id,
|
next(
|
||||||
next(filter(lambda x: x.deviceID == 552, bee.actuators)).id,
|
(actuator.id for actuator in bee.actuators if actuator.deviceID == 551),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
next(
|
||||||
|
(actuator.id for actuator in bee.actuators if actuator.deviceID == 552),
|
||||||
|
None,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
for bee_id, bee in coordinator.data.bees.items()
|
for bee_id, bee in coordinator.data.bees.items()
|
||||||
if bee.productID == 47
|
if bee.productID in COVER_IDS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,19 +60,19 @@ class MBLight(MicroBeesActuatorEntity, LightEntity):
|
|||||||
sendCommand = await self.coordinator.microbees.sendCommand(
|
sendCommand = await self.coordinator.microbees.sendCommand(
|
||||||
self.actuator_id, 1, color=self._attr_rgbw_color
|
self.actuator_id, 1, color=self._attr_rgbw_color
|
||||||
)
|
)
|
||||||
if sendCommand:
|
if not sendCommand:
|
||||||
|
raise HomeAssistantError(f"Failed to turn on {self.name}")
|
||||||
|
|
||||||
self.actuator.value = True
|
self.actuator.value = True
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
else:
|
|
||||||
raise HomeAssistantError(f"Failed to turn on {self.name}")
|
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn off the light."""
|
"""Turn off the light."""
|
||||||
sendCommand = await self.coordinator.microbees.sendCommand(
|
sendCommand = await self.coordinator.microbees.sendCommand(
|
||||||
self.actuator_id, 0, color=self._attr_rgbw_color
|
self.actuator_id, 0, color=self._attr_rgbw_color
|
||||||
)
|
)
|
||||||
if sendCommand:
|
if not sendCommand:
|
||||||
|
raise HomeAssistantError(f"Failed to turn off {self.name}")
|
||||||
|
|
||||||
self.actuator.value = False
|
self.actuator.value = False
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
else:
|
|
||||||
raise HomeAssistantError(f"Failed to turn off {self.name}")
|
|
||||||
|
@ -19,7 +19,10 @@
|
|||||||
"missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
|
"missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
|
||||||
"authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]",
|
"authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]",
|
||||||
"no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]",
|
"no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]",
|
||||||
"user_rejected_authorize": "[%key:common::config_flow::abort::oauth2_user_rejected_authorize%]"
|
"user_rejected_authorize": "[%key:common::config_flow::abort::oauth2_user_rejected_authorize%]",
|
||||||
|
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||||
|
"unknown": "[%key:common::config_flow::error::unknown%]",
|
||||||
|
"wrong_account": "You can only reauthenticate this entry with the same microBees account."
|
||||||
},
|
},
|
||||||
"create_entry": {
|
"create_entry": {
|
||||||
"default": "[%key:common::config_flow::create_entry::authenticated%]"
|
"default": "[%key:common::config_flow::create_entry::authenticated%]"
|
||||||
|
@ -56,17 +56,17 @@ class MBSwitch(MicroBeesActuatorEntity, SwitchEntity):
|
|||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn on the switch."""
|
"""Turn on the switch."""
|
||||||
send_command = await self.coordinator.microbees.sendCommand(self.actuator_id, 1)
|
send_command = await self.coordinator.microbees.sendCommand(self.actuator_id, 1)
|
||||||
if send_command:
|
if not send_command:
|
||||||
|
raise HomeAssistantError(f"Failed to turn on {self.name}")
|
||||||
|
|
||||||
self.actuator.value = True
|
self.actuator.value = True
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
else:
|
|
||||||
raise HomeAssistantError(f"Failed to turn on {self.name}")
|
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn off the switch."""
|
"""Turn off the switch."""
|
||||||
send_command = await self.coordinator.microbees.sendCommand(self.actuator_id, 0)
|
send_command = await self.coordinator.microbees.sendCommand(self.actuator_id, 0)
|
||||||
if send_command:
|
if not send_command:
|
||||||
|
raise HomeAssistantError(f"Failed to turn off {self.name}")
|
||||||
|
|
||||||
self.actuator.value = False
|
self.actuator.value = False
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
else:
|
|
||||||
raise HomeAssistantError(f"Failed to turn off {self.name}")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user