1 """The sms component."""
5 import voluptuous
as vol
24 from .coordinator
import NetworkCoordinator, SignalCoordinator
25 from .gateway
import create_sms_gateway
27 _LOGGER = logging.getLogger(__name__)
29 PLATFORMS = [Platform.SENSOR]
31 SMS_CONFIG_SCHEMA = {vol.Required(CONF_DEVICE): cv.isdevice}
33 CONFIG_SCHEMA = vol.Schema(
37 cv.deprecated(CONF_DEVICE),
42 extra=vol.ALLOW_EXTRA,
46 async
def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
47 """Configure Gammu state machine."""
48 hass.data.setdefault(DOMAIN, {})
49 hass.data[HASS_CONFIG] = config
54 """Configure Gammu state machine."""
56 device = entry.data[CONF_DEVICE]
57 connection_mode =
"at"
58 baud_speed = entry.data.get(CONF_BAUD_SPEED, DEFAULT_BAUD_SPEED)
59 if baud_speed != DEFAULT_BAUD_SPEED:
60 connection_mode += baud_speed
61 config = {
"Device": device,
"Connection": connection_mode}
62 _LOGGER.debug(
"Connecting mode:%s", connection_mode)
71 await signal_coordinator.async_config_entry_first_refresh()
72 await network_coordinator.async_config_entry_first_refresh()
74 hass.data.setdefault(DOMAIN, {})
75 hass.data[DOMAIN][SMS_GATEWAY] = {
76 SIGNAL_COORDINATOR: signal_coordinator,
77 NETWORK_COORDINATOR: network_coordinator,
81 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
85 hass.async_create_task(
86 discovery.async_load_platform(
91 hass.data[HASS_CONFIG],
98 """Unload a config entry."""
99 unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
101 gateway = hass.data[DOMAIN].pop(SMS_GATEWAY)[GATEWAY]
102 await gateway.terminate_async()
def create_sms_gateway(config, hass)
bool async_setup(HomeAssistant hass, ConfigType config)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)