Remove aws_* notify platforms (#22698)

This commit is contained in:
Jason Hu 2019-04-03 20:14:02 -07:00 committed by Paulus Schoutsen
parent a85bcce857
commit 6aac49de7e
9 changed files with 14 additions and 274 deletions

View file

@ -47,9 +47,6 @@ omit =
homeassistant/components/august/*
homeassistant/components/automatic/device_tracker.py
homeassistant/components/avion/light.py
homeassistant/components/aws_lambda/notify.py
homeassistant/components/aws_sns/notify.py
homeassistant/components/aws_sqs/notify.py
homeassistant/components/baidu/tts.py
homeassistant/components/bbb_gpio/*
homeassistant/components/bbox/device_tracker.py

View file

@ -47,31 +47,18 @@ homeassistant/components/*/zwave.py @home-assistant/z-wave
homeassistant/components/hassio/* @home-assistant/hassio
# Individual platforms
homeassistant/components/notify/aws_lambda.py @robbiet480
homeassistant/components/notify/aws_sns.py @robbiet480
homeassistant/components/notify/aws_sqs.py @robbiet480
homeassistant/components/notify/file.py @fabaff
homeassistant/components/notify/flock.py @fabaff
homeassistant/components/notify/gntp.py @robbiet480
homeassistant/components/notify/html5.py @robbiet480
homeassistant/components/notify/mastodon.py @fabaff
homeassistant/components/notify/smtp.py @fabaff
homeassistant/components/notify/syslog.py @fabaff
homeassistant/components/notify/twilio_call.py @robbiet480
homeassistant/components/notify/twilio_sms.py @robbiet480
homeassistant/components/notify/xmpp.py @fabaff
homeassistant/components/notify/yessssms.py @flowolf
homeassistant/components/tts/amazon_polly.py @robbiet480
# A
homeassistant/components/airvisual/sensor.py @bachya
homeassistant/components/alarm_control_panel/manual_mqtt.py @colinodell
homeassistant/components/alpha_vantage/sensor.py @fabaff
homeassistant/components/amazon_polly/* @robbiet480
homeassistant/components/ambient_station/* @bachya
homeassistant/components/arduino/* @fabaff
homeassistant/components/arest/* @fabaff
homeassistant/components/asuswrt/device_tracker.py @kennedyshead
homeassistant/components/automatic/device_tracker.py @armills
homeassistant/components/aws/* @awarecan @robbiet480
homeassistant/components/axis/* @kane610
# B
@ -112,10 +99,11 @@ homeassistant/components/eq3btsmart/climate.py @rytilahti
homeassistant/components/esphome/* @OttoWinter
# F
homeassistant/components/file/sensor.py @fabaff
homeassistant/components/file/* @fabaff
homeassistant/components/filter/sensor.py @dgomes
homeassistant/components/fitbit/sensor.py @robbiet480
homeassistant/components/fixer/sensor.py @fabaff
homeassistant/components/flock/notify.py @fabaff
homeassistant/components/flunearyou/sensor.py @bachya
homeassistant/components/foursquare/* @robbiet480
homeassistant/components/freebox/* @snoof85
@ -124,6 +112,7 @@ homeassistant/components/freebox/* @snoof85
homeassistant/components/gearbest/sensor.py @HerrHofrat
homeassistant/components/gitter/sensor.py @fabaff
homeassistant/components/glances/sensor.py @fabaff
homeassistant/components/gntp/notify.py @robbiet480
homeassistant/components/google_travel_time/sensor.py @robbiet480
homeassistant/components/googlehome/* @ludeeus
homeassistant/components/gpsd/sensor.py @fabaff
@ -136,6 +125,7 @@ homeassistant/components/hikvision/binary_sensor.py @mezz64
homeassistant/components/history_graph/* @andrey-git
homeassistant/components/hive/* @Rendili @KJonline
homeassistant/components/homekit/* @cdce8p
homeassistant/components/html5/notify.py @robbiet480
homeassistant/components/huawei_lte/* @scop
homeassistant/components/huawei_router/device_tracker.py @abmantis
@ -165,6 +155,7 @@ homeassistant/components/liveboxplaytv/media_player.py @pschmitt
homeassistant/components/luftdaten/* @fabaff
# M
homeassistant/components/mastodon/notify.py @fabaff
homeassistant/components/matrix/* @tinloaf
homeassistant/components/mediaroom/media_player.py @dgomes
homeassistant/components/melissa/* @kennedyshead
@ -181,6 +172,7 @@ homeassistant/components/mystrom/* @fabaff
# N
homeassistant/components/nello/lock.py @pschmitt
homeassistant/components/ness_alarm/* @nickw444
homeassistant/components/nest/* @awarecan
homeassistant/components/netdata/sensor.py @fabaff
homeassistant/components/nissan_leaf/* @filcole
homeassistant/components/nmbs/sensor.py @thibmaek
@ -225,6 +217,7 @@ homeassistant/components/shodan/sensor.py @fabaff
homeassistant/components/simplisafe/* @bachya
homeassistant/components/sma/sensor.py @kellerza
homeassistant/components/smartthings/* @andrewsayre
homeassistant/components/smtp/notify.py @fabaff
homeassistant/components/sonos/* @amelchio
homeassistant/components/spaceapi/* @fabaff
homeassistant/components/spider/* @peternijssen
@ -234,6 +227,7 @@ homeassistant/components/swiss_*/* @fabaff
homeassistant/components/switchbot/switch.py @danielhiversen
homeassistant/components/switchmate/switch.py @danielhiversen
homeassistant/components/synology_srm/device_tracker.py @aerialls
homeassistant/components/syslog/notify.py @fabaff
homeassistant/components/sytadin/sensor.py @gautric
# T
@ -252,6 +246,8 @@ homeassistant/components/toon/* @frenck
homeassistant/components/tplink/* @rytilahti
homeassistant/components/traccar/device_tracker.py @ludeeus
homeassistant/components/tradfri/* @ggravlingen
homeassistant/components/twilio_call/notify.py @robbiet480
homeassistant/components/twilio_sms/notify.py @robbiet480
# U
homeassistant/components/uber/sensor.py @robbiet480
@ -276,11 +272,13 @@ homeassistant/components/xfinity/device_tracker.py @cisasteelersfan
homeassistant/components/xiaomi_aqara/* @danielhiversen @syssi
homeassistant/components/xiaomi_miio/* @rytilahti @syssi
homeassistant/components/xiaomi_tv/media_player.py @fattdev
homeassistant/components/xmpp/notify.py @fabaff
# Y
homeassistant/components/yamaha_musiccast/* @jalmeroth
homeassistant/components/yeelight/* @rytilahti @zewelor
homeassistant/components/yeelightsunflower/light.py @lindsaymarkward
homeassistant/components/yessssms/notify.py @flowolf
homeassistant/components/yi/camera.py @bachya
# Z

View file

@ -1 +0,0 @@
"""The aws_lambda component."""

View file

@ -1,89 +0,0 @@
"""AWS Lambda platform for notify component."""
import base64
import json
import logging
import voluptuous as vol
from homeassistant.const import CONF_NAME, CONF_PLATFORM
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.json import JSONEncoder
from homeassistant.components.notify import (ATTR_TARGET, PLATFORM_SCHEMA,
BaseNotificationService)
REQUIREMENTS = ['boto3==1.9.16']
_LOGGER = logging.getLogger(__name__)
CONF_REGION = 'region_name'
CONF_ACCESS_KEY_ID = 'aws_access_key_id'
CONF_SECRET_ACCESS_KEY = 'aws_secret_access_key'
CONF_PROFILE_NAME = 'profile_name'
CONF_CONTEXT = 'context'
ATTR_CREDENTIALS = 'credentials'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_REGION, default='us-east-1'): cv.string,
vol.Inclusive(CONF_ACCESS_KEY_ID, ATTR_CREDENTIALS): cv.string,
vol.Inclusive(CONF_SECRET_ACCESS_KEY, ATTR_CREDENTIALS): cv.string,
vol.Exclusive(CONF_PROFILE_NAME, ATTR_CREDENTIALS): cv.string,
vol.Optional(CONF_CONTEXT, default=dict()): vol.Coerce(dict)
})
def get_service(hass, config, discovery_info=None):
"""Get the AWS Lambda notification service."""
_LOGGER.warning(
"aws_lambda notify platform is deprecated, please replace it"
" with aws component. This config will become invalid in version 0.92."
" See https://www.home-assistant.io/components/aws/ for details."
)
context_str = json.dumps({'custom': config[CONF_CONTEXT]}, cls=JSONEncoder)
context_b64 = base64.b64encode(context_str.encode('utf-8'))
context = context_b64.decode('utf-8')
import boto3
aws_config = config.copy()
del aws_config[CONF_PLATFORM]
del aws_config[CONF_NAME]
del aws_config[CONF_CONTEXT]
profile = aws_config.get(CONF_PROFILE_NAME)
if profile is not None:
boto3.setup_default_session(profile_name=profile)
del aws_config[CONF_PROFILE_NAME]
lambda_client = boto3.client("lambda", **aws_config)
return AWSLambda(lambda_client, context)
class AWSLambda(BaseNotificationService):
"""Implement the notification service for the AWS Lambda service."""
def __init__(self, lambda_client, context):
"""Initialize the service."""
self.client = lambda_client
self.context = context
def send_message(self, message="", **kwargs):
"""Send notification to specified LAMBDA ARN."""
targets = kwargs.get(ATTR_TARGET)
if not targets:
_LOGGER.info("At least 1 target is required")
return
for target in targets:
cleaned_kwargs = dict((k, v) for k, v in kwargs.items() if v)
payload = {"message": message}
payload.update(cleaned_kwargs)
self.client.invoke(FunctionName=target,
Payload=json.dumps(payload),
ClientContext=self.context)

View file

@ -1 +0,0 @@
"""The aws_sns component."""

View file

@ -1,79 +0,0 @@
"""AWS SNS platform for notify component."""
import json
import logging
import voluptuous as vol
from homeassistant.const import CONF_NAME, CONF_PLATFORM
import homeassistant.helpers.config_validation as cv
from homeassistant.components.notify import (
ATTR_TARGET, ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA,
BaseNotificationService)
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ["boto3==1.9.16"]
CONF_REGION = 'region_name'
CONF_ACCESS_KEY_ID = 'aws_access_key_id'
CONF_SECRET_ACCESS_KEY = 'aws_secret_access_key'
CONF_PROFILE_NAME = 'profile_name'
ATTR_CREDENTIALS = 'credentials'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_REGION, default='us-east-1'): cv.string,
vol.Inclusive(CONF_ACCESS_KEY_ID, ATTR_CREDENTIALS): cv.string,
vol.Inclusive(CONF_SECRET_ACCESS_KEY, ATTR_CREDENTIALS): cv.string,
vol.Exclusive(CONF_PROFILE_NAME, ATTR_CREDENTIALS): cv.string,
})
def get_service(hass, config, discovery_info=None):
"""Get the AWS SNS notification service."""
_LOGGER.warning(
"aws_sns notify platform is deprecated, please replace it"
" with aws component. This config will become invalid in version 0.92."
" See https://www.home-assistant.io/components/aws/ for details."
)
import boto3
aws_config = config.copy()
del aws_config[CONF_PLATFORM]
del aws_config[CONF_NAME]
profile = aws_config.get(CONF_PROFILE_NAME)
if profile is not None:
boto3.setup_default_session(profile_name=profile)
del aws_config[CONF_PROFILE_NAME]
sns_client = boto3.client("sns", **aws_config)
return AWSSNS(sns_client)
class AWSSNS(BaseNotificationService):
"""Implement the notification service for the AWS SNS service."""
def __init__(self, sns_client):
"""Initialize the service."""
self.client = sns_client
def send_message(self, message="", **kwargs):
"""Send notification to specified SNS ARN."""
targets = kwargs.get(ATTR_TARGET)
if not targets:
_LOGGER.info("At least 1 target is required")
return
message_attributes = {k: {"StringValue": json.dumps(v),
"DataType": "String"}
for k, v in kwargs.items() if v}
for target in targets:
self.client.publish(TargetArn=target, Message=message,
Subject=kwargs.get(ATTR_TITLE,
ATTR_TITLE_DEFAULT),
MessageAttributes=message_attributes)

View file

@ -1 +0,0 @@
"""The aws_sqs component."""

View file

@ -1,81 +0,0 @@
"""AWS SQS platform for notify component."""
import json
import logging
import voluptuous as vol
from homeassistant.const import CONF_NAME, CONF_PLATFORM
import homeassistant.helpers.config_validation as cv
from homeassistant.components.notify import (ATTR_TARGET, PLATFORM_SCHEMA,
BaseNotificationService)
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ["boto3==1.9.16"]
CONF_REGION = 'region_name'
CONF_ACCESS_KEY_ID = 'aws_access_key_id'
CONF_SECRET_ACCESS_KEY = 'aws_secret_access_key'
CONF_PROFILE_NAME = 'profile_name'
ATTR_CREDENTIALS = 'credentials'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_REGION, default='us-east-1'): cv.string,
vol.Inclusive(CONF_ACCESS_KEY_ID, ATTR_CREDENTIALS): cv.string,
vol.Inclusive(CONF_SECRET_ACCESS_KEY, ATTR_CREDENTIALS): cv.string,
vol.Exclusive(CONF_PROFILE_NAME, ATTR_CREDENTIALS): cv.string,
})
def get_service(hass, config, discovery_info=None):
"""Get the AWS SQS notification service."""
_LOGGER.warning(
"aws_sqs notify platform is deprecated, please replace it"
" with aws component. This config will become invalid in version 0.92."
" See https://www.home-assistant.io/components/aws/ for details."
)
import boto3
aws_config = config.copy()
del aws_config[CONF_PLATFORM]
del aws_config[CONF_NAME]
profile = aws_config.get(CONF_PROFILE_NAME)
if profile is not None:
boto3.setup_default_session(profile_name=profile)
del aws_config[CONF_PROFILE_NAME]
sqs_client = boto3.client("sqs", **aws_config)
return AWSSQS(sqs_client)
class AWSSQS(BaseNotificationService):
"""Implement the notification service for the AWS SQS service."""
def __init__(self, sqs_client):
"""Initialize the service."""
self.client = sqs_client
def send_message(self, message="", **kwargs):
"""Send notification to specified SQS ARN."""
targets = kwargs.get(ATTR_TARGET)
if not targets:
_LOGGER.info("At least 1 target is required")
return
for target in targets:
cleaned_kwargs = dict((k, v) for k, v in kwargs.items() if v)
message_body = {"message": message}
message_body.update(cleaned_kwargs)
message_attributes = {}
for key, val in cleaned_kwargs.items():
message_attributes[key] = {"StringValue": json.dumps(val),
"DataType": "String"}
self.client.send_message(QueueUrl=target,
MessageBody=json.dumps(message_body),
MessageAttributes=message_attributes)

View file

@ -237,9 +237,6 @@ blockchain==1.4.4
# homeassistant.components.route53
# homeassistant.components.amazon_polly.tts
# homeassistant.components.aws_lambda.notify
# homeassistant.components.aws_sns.notify
# homeassistant.components.aws_sqs.notify
boto3==1.9.16
# homeassistant.components.braviatv.media_player