1 """Support for MotionMount numeric control."""
14 from .const
import DOMAIN
15 from .entity
import MotionMountEntity
19 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
21 """Set up Vogel's MotionMount from a config entry."""
22 mm: motionmount.MotionMount = hass.data[DOMAIN][entry.entry_id]
33 """The target extension position of a MotionMount."""
35 _attr_native_max_value = 100
36 _attr_native_min_value = 0
37 _attr_native_unit_of_measurement = PERCENTAGE
38 _attr_translation_key =
"motionmount_extension"
40 def __init__(self, mm: motionmount.MotionMount, config_entry: ConfigEntry) ->
None:
41 """Initialize Extension number."""
47 """Get native value."""
48 return float(self.
mmmm.extension
or 0)
51 """Set the new value for extension."""
53 await self.
mmmm.set_extension(
int(value))
54 except (TimeoutError, socket.gaierror)
as ex:
56 translation_domain=DOMAIN,
57 translation_key=
"failed_communication",
62 """The target turn position of a MotionMount."""
64 _attr_native_max_value = 100
65 _attr_native_min_value = -100
66 _attr_native_unit_of_measurement = PERCENTAGE
67 _attr_translation_key =
"motionmount_turn"
69 def __init__(self, mm: motionmount.MotionMount, config_entry: ConfigEntry) ->
None:
70 """Initialize Turn number."""
76 """Get native value."""
77 return float(self.
mmmm.turn
or 0) * -1
80 """Set the new value for turn."""
82 await self.
mmmm.set_turn(
int(value * -1))
83 except (TimeoutError, socket.gaierror)
as ex:
85 translation_domain=DOMAIN,
86 translation_key=
"failed_communication",
None async_set_native_value(self, float value)
None __init__(self, motionmount.MotionMount mm, ConfigEntry config_entry)
None async_set_native_value(self, float value)
None __init__(self, motionmount.MotionMount mm, ConfigEntry config_entry)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)