Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b2e230b
Merge tag '0.108.7' of https://github.com/home-assistant/core into dev
ocalvo Apr 22, 2020
a22a3ec
Merge branch 'dev' of https://github.com/home-assistant/core into dev
ocalvo Apr 22, 2020
8a9417d
Merge branch 'dev' of https://github.com/home-assistant/core into dev
ocalvo May 22, 2020
2983c2f
Merge branch 'dev' of https://github.com/home-assistant/core into dev
ocalvo Jun 26, 2020
480647a
Merge branch 'dev' of https://github.com/home-assistant/core into dev
ocalvo Jul 6, 2020
cd3e034
Merge branch 'dev' of https://github.com/home-assistant/core into dev
ocalvo Aug 5, 2021
f1eefcf
Merge branch 'dev' of https://github.com/home-assistant/core into dev
ocalvo Aug 7, 2021
53be47f
Merge branch 'home-assistant:dev' into dev
ocalvo Mar 18, 2022
bea8522
Merge branch 'dev' of https://github.com/home-assistant/core into Sup…
ocalvo Mar 18, 2022
6b4b625
Add support to specify baud speed
ocalvo Mar 18, 2022
4f8e626
Apply PR feedback
ocalvo Mar 18, 2022
9bf5b64
Apply PR feedback
ocalvo Mar 18, 2022
ca3716d
Support config via yaml
ocalvo Mar 18, 2022
e5125fe
Fix comparasion bug
ocalvo Mar 18, 2022
40b1da6
Remove deprecated yaml config
ocalvo Mar 19, 2022
08b2036
Deprecate yaml configuration
ocalvo Mar 19, 2022
fdba40b
Merge branch 'dev' of https://github.com/home-assistant/core into Sup…
ocalvo Mar 20, 2022
0276563
Fix a bug where a bad AT connection is formed
ocalvo Mar 20, 2022
90a669f
Minor refactoring
ocalvo Mar 20, 2022
e319f06
Use default value for dict.get
ocalvo Mar 20, 2022
c03d18d
Update homeassistant/components/sms/__init__.py
ocalvo Mar 30, 2022
46b40a8
Update homeassistant/components/sms/strings.json
ocalvo Mar 30, 2022
01a453b
Update homeassistant/components/sms/config_flow.py
ocalvo Mar 30, 2022
b81d18a
Update homeassistant/components/sms/config_flow.py
ocalvo Mar 31, 2022
25f93c6
Update __init__.py
ocalvo Mar 31, 2022
a91a743
Update const.py
ocalvo Mar 31, 2022
9e864a5
Merge branch 'home-assistant:dev' into dev
ocalvo Apr 6, 2022
56d08d5
Merge branch 'dev' into SupportBaudRate
ocalvo Apr 23, 2022
78403b3
Merge branch 'dev' of https://github.com/ocalvo/home-assistant into S…
ocalvo Apr 29, 2022
f73bab2
Apply PR feedback
ocalvo Apr 29, 2022
a954c2f
Merge branch 'SupportBaudRate' of https://github.com/ocalvo/home-assi…
ocalvo Apr 29, 2022
d12a471
Merge branch 'dev' into SupportBaudRate
ocalvo Apr 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions homeassistant/components/sms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""The sms component."""
import logging

import voluptuous as vol

from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
Expand All @@ -7,13 +9,24 @@
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType

from .const import DOMAIN, SMS_GATEWAY
from .const import CONF_BAUD_SPEED, DEFAULT_BAUD_SPEED, DOMAIN, SMS_GATEWAY
from .gateway import create_sms_gateway

_LOGGER = logging.getLogger(__name__)

PLATFORMS = [Platform.SENSOR]

SMS_CONFIG_SCHEMA = {vol.Required(CONF_DEVICE): cv.isdevice}

CONFIG_SCHEMA = vol.Schema(
{DOMAIN: vol.Schema({vol.Required(CONF_DEVICE): cv.isdevice})},
{
DOMAIN: vol.Schema(
vol.All(
cv.deprecated(CONF_DEVICE),
SMS_CONFIG_SCHEMA,
),
)
},
extra=vol.ALLOW_EXTRA,
)

Expand All @@ -39,7 +52,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Configure Gammu state machine."""

device = entry.data[CONF_DEVICE]
config = {"Device": device, "Connection": "at"}
connection_mode = "at"
baud_speed = entry.data.get(CONF_BAUD_SPEED, DEFAULT_BAUD_SPEED)
if baud_speed != DEFAULT_BAUD_SPEED:
connection_mode += baud_speed
config = {"Device": device, "Connection": connection_mode}
_LOGGER.debug("Connecting mode:%s", connection_mode)
gateway = await create_sms_gateway(config, hass)
if not gateway:
return False
Expand Down
20 changes: 16 additions & 4 deletions homeassistant/components/sms/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@

from homeassistant import config_entries, core, exceptions
from homeassistant.const import CONF_DEVICE
from homeassistant.helpers import selector

from .const import DOMAIN
from .const import CONF_BAUD_SPEED, DEFAULT_BAUD_SPEED, DEFAULT_BAUD_SPEEDS, DOMAIN
from .gateway import create_sms_gateway

_LOGGER = logging.getLogger(__name__)

DATA_SCHEMA = vol.Schema({vol.Required(CONF_DEVICE): str})
DATA_SCHEMA = vol.Schema(
{
vol.Required(CONF_DEVICE): str,
vol.Optional(CONF_BAUD_SPEED, default=DEFAULT_BAUD_SPEED): selector.selector(
{"select": {"options": DEFAULT_BAUD_SPEEDS}}
),
}
)


async def get_imei_from_config(hass: core.HomeAssistant, data):
Expand All @@ -21,13 +29,17 @@ async def get_imei_from_config(hass: core.HomeAssistant, data):
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
device = data[CONF_DEVICE]
config = {"Device": device, "Connection": "at"}
connection_mode = "at"
baud_speed = data.get(CONF_BAUD_SPEED, DEFAULT_BAUD_SPEED)
if baud_speed != DEFAULT_BAUD_SPEED:
connection_mode += baud_speed
config = {"Device": device, "Connection": connection_mode}
gateway = await create_sms_gateway(config, hass)
if not gateway:
raise CannotConnect
try:
imei = await gateway.get_imei_async()
except gammu.GSMError as err:
except gammu.GSMError as err: # pylint: disable=no-member
raise CannotConnect from err
finally:
await gateway.terminate_async()
Expand Down
24 changes: 24 additions & 0 deletions homeassistant/components/sms/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,27 @@
DOMAIN = "sms"
SMS_GATEWAY = "SMS_GATEWAY"
SMS_STATE_UNREAD = "UnRead"
CONF_BAUD_SPEED = "baud_speed"
DEFAULT_BAUD_SPEED = "0"
DEFAULT_BAUD_SPEEDS = [
{"value": DEFAULT_BAUD_SPEED, "label": "Auto"},
{"value": "50", "label": "50"},
{"value": "75", "label": "75"},
{"value": "110", "label": "110"},
{"value": "134", "label": "134"},
{"value": "150", "label": "150"},
{"value": "200", "label": "200"},
{"value": "300", "label": "300"},
{"value": "600", "label": "600"},
{"value": "1200", "label": "1200"},
{"value": "1800", "label": "1800"},
{"value": "2400", "label": "2400"},
{"value": "4800", "label": "4800"},
{"value": "9600", "label": "9600"},
{"value": "19200", "label": "19200"},
{"value": "28800", "label": "28800"},
{"value": "38400", "label": "38400"},
{"value": "57600", "label": "57600"},
{"value": "76800", "label": "76800"},
{"value": "115200", "label": "115200"},
]
1 change: 1 addition & 0 deletions homeassistant/components/sms/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Gateway:

def __init__(self, config, hass):
"""Initialize the sms gateway."""
_LOGGER.debug("Init with connection mode:%s", config["Connection"])
self._worker = GammuAsyncWorker(self.sms_pull)
self._worker.configure(config)
self._hass = hass
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/sms/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"step": {
"user": {
"title": "Connect to the modem",
"data": { "device": "Device" }
"data": {
"device": "Device",
"baud_speed": "Baud Speed"
}
}
},
"error": {
Expand Down