Allow disabling device creation. Fix #31
This commit is contained in:
parent
61d23a8136
commit
9fa91eec3c
18
README.md
18
README.md
@ -70,6 +70,24 @@ browser_mod:
|
||||
```
|
||||
This does not apply to devices with an alias.
|
||||
|
||||
### Disabling entities
|
||||
`browser_mod` creates a number of entities, which is explained below. In some cases, you may not want to do that. If so, add a list of entity types you do *not* want to add to a `disable` section, either for each device, or globally to ignore for all unknown devices:
|
||||
|
||||
E.g. to disable the `light` and `media_player` for the device aliased to `arrakis`, AND disable *all* entities for all devices which *don't* have an alias:
|
||||
|
||||
```yaml
|
||||
browser_mod:
|
||||
devices:
|
||||
99980b13-dabc9563:
|
||||
name: arrakis
|
||||
disable:
|
||||
- light
|
||||
- media_player
|
||||
disable:
|
||||
- all
|
||||
````
|
||||
|
||||
|
||||
## Entities
|
||||
Once `browser_mod` is installed, loading up your Home Assistant frontend on a new *device* will create three to five new devices.
|
||||
|
||||
|
@ -74,6 +74,7 @@ class BrowserModConnection:
|
||||
'sensor',
|
||||
self.deviceID,
|
||||
self)
|
||||
if self.sensor:
|
||||
self.sensor.data = data.get('browser')
|
||||
|
||||
if data.get('player'):
|
||||
@ -82,6 +83,7 @@ class BrowserModConnection:
|
||||
'media_player',
|
||||
self.deviceID,
|
||||
self)
|
||||
if self.media_player:
|
||||
self.media_player.data = data.get('player')
|
||||
|
||||
if data.get('screen'):
|
||||
@ -90,6 +92,7 @@ class BrowserModConnection:
|
||||
'light',
|
||||
self.deviceID,
|
||||
self)
|
||||
if self.screen:
|
||||
self.screen.data = data.get('screen')
|
||||
|
||||
if data.get('fully'):
|
||||
@ -98,6 +101,7 @@ class BrowserModConnection:
|
||||
'binary_sensor',
|
||||
self.deviceID,
|
||||
self)
|
||||
if self.fully:
|
||||
self.fully.data = data.get('fully')
|
||||
|
||||
if data.get('camera'):
|
||||
@ -106,5 +110,6 @@ class BrowserModConnection:
|
||||
'camera',
|
||||
self.deviceID,
|
||||
self)
|
||||
if self.camera:
|
||||
self.camera.data = data.get('camera')
|
||||
|
||||
|
@ -11,6 +11,8 @@ DATA_CONFIG = "config"
|
||||
|
||||
CONFIG_DEVICES = "devices"
|
||||
CONFIG_PREFIX = "prefix"
|
||||
CONFIG_DISABLE = "disable"
|
||||
CONFIG_DISABLE_ALL = "all"
|
||||
|
||||
WS_ROOT = DOMAIN
|
||||
WS_CONNECT = "{}/connect".format(WS_ROOT)
|
||||
|
@ -2,7 +2,7 @@ import logging
|
||||
|
||||
from homeassistant.helpers.entity import Entity, async_generate_entity_id
|
||||
|
||||
from .const import DOMAIN, DATA_DEVICES, DATA_ALIASES, DATA_ADDERS, CONFIG_DEVICES, DATA_CONFIG, CONFIG_PREFIX
|
||||
from .const import DOMAIN, DATA_DEVICES, DATA_ALIASES, DATA_ADDERS, CONFIG_DEVICES, DATA_CONFIG, CONFIG_PREFIX, CONFIG_DISABLE, CONFIG_DISABLE_ALL
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -20,6 +20,13 @@ def get_config(hass, deviceID):
|
||||
return config.get(deviceID, config.get(deviceID.replace('-','_'), {}))
|
||||
|
||||
def create_entity(hass, platform, deviceID, connection):
|
||||
conf = get_config(hass, deviceID)
|
||||
if conf and (platform in conf.get(CONFIG_DISABLE, [])
|
||||
or CONFIG_DISABLE_ALL in conf.get(CONFIG_DISABLE, [])):
|
||||
return None
|
||||
if not conf and (platform in hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_DISABLE, [])
|
||||
or CONFIG_DISABLE_ALL in hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_DISABLE, [])):
|
||||
return None
|
||||
adder = hass.data[DOMAIN][DATA_ADDERS][platform]
|
||||
entity = adder(hass, deviceID, connection, get_alias(hass, deviceID))
|
||||
return entity
|
||||
|
@ -6,7 +6,7 @@
|
||||
"scripts": {
|
||||
"build": "webpack",
|
||||
"watch": "webpack --watch --mode=development",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"update-card-tools": "npm uninstall card-tools && npm install thomasloven/lovelace-card-tools"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Thomas Lovén",
|
||||
|
Loading…
x
Reference in New Issue
Block a user