Add optional rtsp_port for Foscam (#22786)

* add optional rtsp port for config

* getting rid of default=None

* removing vol.Any
pull/22791/head
Chris Helming 2019-04-05 23:02:38 -04:00 committed by Jason Hunter
parent 192ed90773
commit 2b490e4486
1 changed files with 8 additions and 5 deletions

View File

@ -14,6 +14,7 @@ _LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['libpyfoscam==1.0']
CONF_IP = 'ip'
CONF_RTSP_PORT = 'rtsp_port'
DEFAULT_NAME = 'Foscam Camera'
DEFAULT_PORT = 88
@ -26,6 +27,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_USERNAME): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_RTSP_PORT): cv.port
})
@ -53,7 +55,8 @@ class FoscamCam(Camera):
self._foscam_session = FoscamCamera(
ip_address, port, self._username, self._password, verbose=False)
self._rtsp_port = None
self._rtsp_port = device_info.get(CONF_RTSP_PORT)
if not self._rtsp_port:
result, response = self._foscam_session.get_port_info()
if result == 0:
self._rtsp_port = response.get('rtspPort') or \