1 """Number entities for Wyoming integration."""
3 from __future__
import annotations
5 from typing
import TYPE_CHECKING, Final
13 from .const
import DOMAIN
14 from .entity
import WyomingSatelliteEntity
17 from .models
import DomainDataItem
19 _MAX_AUTO_GAIN: Final = 31
20 _MIN_VOLUME_MULTIPLIER: Final = 0.1
21 _MAX_VOLUME_MULTIPLIER: Final = 10.0
26 config_entry: ConfigEntry,
27 async_add_entities: AddEntitiesCallback,
29 """Set up Wyoming number entities."""
30 item: DomainDataItem = hass.data[DOMAIN][config_entry.entry_id]
33 assert item.device
is not None
44 """Entity to represent auto gain amount."""
48 translation_key=
"auto_gain",
49 entity_category=EntityCategory.CONFIG,
51 _attr_should_poll =
False
52 _attr_native_min_value = 0
53 _attr_native_max_value = _MAX_AUTO_GAIN
54 _attr_native_value = 0
57 """When entity is added to Home Assistant."""
66 auto_gain =
int(
max(0,
min(_MAX_AUTO_GAIN, value)))
69 self.
_device_device.set_auto_gain(auto_gain)
73 """Entity to represent microphone volume multiplier."""
76 key=
"volume_multiplier",
77 translation_key=
"volume_multiplier",
78 entity_category=EntityCategory.CONFIG,
80 _attr_should_poll =
False
81 _attr_native_min_value = _MIN_VOLUME_MULTIPLIER
82 _attr_native_max_value = _MAX_VOLUME_MULTIPLIER
83 _attr_native_step = 0.1
84 _attr_native_value = 1.0
87 """When entity is added to Home Assistant."""
90 if (last_number_data
is not None)
and (
91 last_number_data.native_value
is not None
98 max(_MIN_VOLUME_MULTIPLIER,
min(_MAX_VOLUME_MULTIPLIER, value))
None async_set_native_value(self, float value)
NumberExtraStoredData|None async_get_last_number_data(self)
None async_added_to_hass(self)
None async_set_native_value(self, float value)
None async_set_native_value(self, float value)
None async_added_to_hass(self)
None async_write_ha_state(self)
State|None async_get_last_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)