1 """Support for the Fibaro devices."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
9 from pyfibaro.fibaro_device
import DeviceModel
14 _LOGGER = logging.getLogger(__name__)
18 """Representation of a Fibaro device entity."""
20 _attr_should_poll =
False
22 def __init__(self, fibaro_device: DeviceModel) ->
None:
23 """Initialize the device."""
25 self.
controllercontroller = fibaro_device.fibaro_controller
26 self.
ha_idha_id = fibaro_device.ha_id
32 if not fibaro_device.visible:
36 """Call when entity is added to hass."""
40 """Update the state."""
45 """Get the level of Fibaro device."""
52 """Get the tilt level of Fibaro device."""
58 """Make a warning in case we don't know how to perform an action."""
60 "Not sure how to %s: %s (available actions: %s)",
67 """Set the level of Fibaro device."""
68 self.
actionaction(
"setValue", level)
72 self.
fibaro_devicefibaro_device.properties[
"brightness"] = level
75 """Set the level2 of Fibaro device."""
76 self.
actionaction(
"setValue2", level)
81 """Turn on the Fibaro device."""
82 self.
actionaction(
"turnOn")
85 """Turn off the Fibaro device."""
86 self.
actionaction(
"turnOff")
88 def call_set_color(self, red: int, green: int, blue: int, white: int) ->
None:
89 """Set the color of Fibaro device."""
94 color_str = f
"{red},{green},{blue},{white}"
95 self.
fibaro_devicefibaro_device.properties[
"color"] = color_str
98 def action(self, cmd: str, *args: Any) ->
None:
99 """Perform an action on the Fibaro HC."""
102 _LOGGER.debug(
"-> %s.%s%s called",
str(self.
ha_idha_id),
str(cmd),
str(args))
108 """Return the current binary state."""
109 return self.
fibaro_devicefibaro_device.value.bool_value(
False)
113 """Return the state attributes of the device."""
114 attr = {
"fibaro_id": self.
fibaro_devicefibaro_device.fibaro_id}
117 attr[ATTR_BATTERY_LEVEL] = self.
fibaro_devicefibaro_device.battery_level
124 """Update the available state of the entity."""
None action(self, str cmd, *Any args)
None set_level2(self, int level)
None dont_know_message(self, str cmd)
bool current_binary_state(self)
None call_set_color(self, int red, int green, int blue, int white)
None set_level(self, int level)
None async_added_to_hass(self)
_attr_entity_registry_visible_default
None _update_callback(self)
Mapping[str, Any] extra_state_attributes(self)
None __init__(self, DeviceModel fibaro_device)
None schedule_update_ha_state(self, bool force_refresh=False)
def register(HomeAssistant hass, Heos controller)
DeviceInfo get_device_info(str coordinates, str name)