Better webrtc config, more README

pull/106/head
Jeff Culverhouse 11 months ago
parent 51d43d3f0d
commit 1bb0177097

@ -16,6 +16,10 @@ Or, we support the following environment variables and defaults:
- `AMCREST_PORT` (optional, default = 80) - `AMCREST_PORT` (optional, default = 80)
- `AMCREST_USERNAME` (optional, default = admin) - `AMCREST_USERNAME` (optional, default = admin)
- `AMCREST_PASSWORD` (required) - `AMCREST_PASSWORD` (required)
- `AMCREST_WEBRTC_HOST` (optional, webrtc hostname for link, along with...)
- `AMCREST_WEBRTC_PORT` (webrtc port, default = 1984)
- `AMCREST_WEBRTC_LINK` (webrtc stream link, default = 'stream.html')
- `AMCREST_WEBRTC_SOURCES` (webrtc "Source" param for each camera, same count and order of AMCREST_HOSTS above)
- `MQTT_USERNAME` (required) - `MQTT_USERNAME` (required)
- `MQTT_PASSWORD` (optional, default = empty password) - `MQTT_PASSWORD` (optional, default = empty password)
@ -29,9 +33,6 @@ Or, we support the following environment variables and defaults:
- `MQTT_PREFIX` (optional, default = amgrest2mqtt) - `MQTT_PREFIX` (optional, default = amgrest2mqtt)
- `MQTT_HOMEASSISTANT` (optional, default = true) - `MQTT_HOMEASSISTANT` (optional, default = true)
- `MQTT_DISCOVERY_PREFIX` (optional, default = 'homeassistant') - `MQTT_DISCOVERY_PREFIX` (optional, default = 'homeassistant')
- `MQTT_WEBRTC_HOST` (optional, webrtc hostname for link, along with...)
- `MQTT_WEBRTC_PORT` (webrtc port, default = 1984)
- `MQTT_WEBRTC_SOURCES` (webrtc "Source" param for each camera, same count and order of AMCREST_HOSTS above)
- `TZ` (required, timezone identifier, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) - `TZ` (required, timezone identifier, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List)
- `STORAGE_UPDATE_INTERVAL` (optional, default = 900) - how often to fetch storage stats (in seconds) - `STORAGE_UPDATE_INTERVAL` (optional, default = 900) - how often to fetch storage stats (in seconds)
@ -50,6 +51,10 @@ It exposes through device discovery a `service` and a `device` with components f
- `config` - device configuration information - `config` - device configuration information
- `storage` - storage stats - `storage` - storage stats
## Snapshots, Area Cards, and WebRTC
The `camera` snapshots work really well for the HomeAssistant `Area` cards on a dashboard - just make this MQTT camera device the only camera for an area and place an `Area` card for that location. The WebRTC option works very well with the <a href="https://github.com/AlexxIT/go2rtc">go2rtc</a> package which is a streaming server that works very well for (my) Amcrest cameras. If you setup the WebRTC config here, the `configuration_url` for the MQTT device will be the streaming RTC link instead of just a link to the hostname (which is arguably more correctly a "configuration" url, but I'd rather have a simple link from the device page to a live stream)
## Device Support ## Device Support
The app supports events for any Amcrest device supported by [`python-amcrest`](https://github.com/tchellomello/python-amcrest). The app supports events for any Amcrest device supported by [`python-amcrest`](https://github.com/tchellomello/python-amcrest).

@ -443,10 +443,11 @@ class AmcrestMqtt(object):
if 'webrtc' in self.amcrest_config: if 'webrtc' in self.amcrest_config:
webrtc_config = self.amcrest_config['webrtc'] webrtc_config = self.amcrest_config['webrtc']
rtc_host = webrtc_config['host'] rtc_host = webrtc_config['host']
rtc_port = webrtc_config['port'] if 'port' in webrtc_config else 1984 rtc_port = webrtc_config['port']
rtc_link = webrtc_config['link']
rtc_source = webrtc_config['sources'].pop(0) rtc_source = webrtc_config['sources'].pop(0)
rtc_url = f'http://{rtc_host}:{rtc_port}/api/frame.jpeg?src={rtc_source}' rtc_url = f'http://{rtc_host}:{rtc_port}/{rtc_link}?src={rtc_source}'
components[self.get_slug(device_id, 'camera')]['entity_picture'] = rtc_url device['device']['configuration_url'] = rtc_url
components[self.get_slug(device_id, 'motion')] = { components[self.get_slug(device_id, 'motion')] = {
'name': 'Motion', 'name': 'Motion',

@ -56,6 +56,12 @@ except:
'password': os.getenv("AMCREST_PASSWORD"), 'password': os.getenv("AMCREST_PASSWORD"),
'storage_update_interval': int(os.getenv("STORAGE_UPDATE_INTERVAL") or 900), 'storage_update_interval': int(os.getenv("STORAGE_UPDATE_INTERVAL") or 900),
'snapshot_update_interval': int(os.getenv("SNAPSHOT_UPDATE_INTERVAL") or 300), 'snapshot_update_interval': int(os.getenv("SNAPSHOT_UPDATE_INTERVAL") or 300),
'webrtc': {
'host': os.getenv("AMCREST_WEBRTC_HOST"),
'port': int(os.getenv("AMCREST_WEBRTC_PORT") or 1984),
'link': os.getenv("AMCREST_WEBRTC_LINK") or 'stream.html',
'sources': os.getenv("AMCREST_WEBRTC_SOURCES"),
},
}, },
'debug': True if os.getenv('DEBUG') else False, 'debug': True if os.getenv('DEBUG') else False,
'hide_ts': True if os.getenv('HIDE_TS') else False, 'hide_ts': True if os.getenv('HIDE_TS') else False,
@ -107,6 +113,8 @@ if 'webrtc' in config['amcrest']:
if config['amcrest']['host_count'] != config['amcrest']['webrtc_sources_count']: if config['amcrest']['host_count'] != config['amcrest']['webrtc_sources_count']:
logger.error('The AMCREST_HOSTS and AMCREST_WEBRTC_SOURCES must have the same number of space-delimited hosts/names') logger.error('The AMCREST_HOSTS and AMCREST_WEBRTC_SOURCES must have the same number of space-delimited hosts/names')
exit(1) exit(1)
if 'port' not in webrtc: webrtc['port'] = 1984
if 'link' not in webrtc: webrtc['link'] = 'stream.html'
if config['amcrest']['password'] is None: if config['amcrest']['password'] is None:
logger.error('Please set the AMCREST_PASSWORD environment variable') logger.error('Please set the AMCREST_PASSWORD environment variable')

Loading…
Cancel
Save