Skip to content

Commit

Permalink
Fixed: Some user got a switch error, this should be solved
Browse files Browse the repository at this point in the history
  • Loading branch information
ualex73 committed Jul 14, 2020
1 parent 35cf43e commit 6ebc174
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ monitor_docker:
| rename | dictionary (Optional) | Dictionary of containers to rename. Default no renaming. |
| sensorname | string (Optional) | Sensor string to format the name used in Home Assistant. Defaults to `{name} {sensor}`, where `{name}` is the container name and `{sensor}` is e.g. Memory, Status, Network speed Up |
| switchname | string (optional) | Switch string to format the name used in Home Assistant. Defaults to `{name}`, where `{name}` is the container name. |
| switch | boolean (Optional) | Enable/Disable the switch entity for all containers. Default is enabled. |
| switchenabled | boolean (Optional) | Enable/Disable the switch entity for all containers. Default is enabled. |

| Monitored Conditions | Description | Unit |
| --------------------------------- | ------------------------------- | ----- |
Expand Down
4 changes: 2 additions & 2 deletions custom_components/monitor_docker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
CONF_CONTAINERS,
CONF_RENAME,
CONF_SENSORNAME,
CONF_SWITCH,
CONF_SWITCHENABLED,
CONF_SWITCHNAME,
CONFIG,
CONTAINER_INFO_ALLINONE,
Expand Down Expand Up @@ -53,7 +53,7 @@
vol.Optional(CONF_CONTAINERS, default=[]): cv.ensure_list,
vol.Optional(CONF_RENAME, default={}): dict,
vol.Optional(CONF_SENSORNAME, default=DEFAULT_SENSORNAME): cv.string,
vol.Optional(CONF_SWITCH, default=True): cv.boolean,
vol.Optional(CONF_SWITCHENABLED, default=True): cv.boolean,
vol.Optional(CONF_SWITCHNAME, default=DEFAULT_SWITCHNAME): cv.string,
vol.Optional(CONF_CERTPATH, default=""): cv.string,
}
Expand Down
2 changes: 1 addition & 1 deletion custom_components/monitor_docker/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
CONF_CONTAINERS = "containers"
CONF_RENAME = "rename"
CONF_SENSORNAME = "sensorname"
CONF_SWITCH = "switch"
CONF_SWITCHENABLED = "switchenabled"
CONF_SWITCHNAME = "switchname"

DEFAULT_NAME = "Docker"
Expand Down
2 changes: 2 additions & 0 deletions custom_components/monitor_docker/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
config = hass.data[DOMAIN][name][CONFIG]
prefix = config[CONF_NAME]

_LOGGER.debug("Setting up sensor(s)")

sensors = []
sensors = [
DockerSensor(api, prefix, variable)
Expand Down
7 changes: 5 additions & 2 deletions custom_components/monitor_docker/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
CONFIG,
CONF_CONTAINERS,
CONF_RENAME,
CONF_SWITCH,
CONF_SWITCHENABLED,
CONF_SWITCHNAME,
CONTAINER,
CONTAINER_INFO_STATE,
Expand All @@ -34,9 +34,12 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
prefix = config[CONF_NAME]

# Don't create any switch if disabled
if not config[CONF_SWITCH]:
if not config[CONF_SWITCHENABLED]:
_LOGGER.debug("Switch(es) are disabled")
return True

_LOGGER.debug("Setting up switch(es)")

switches = []

# We support add/re-add of a container
Expand Down
7 changes: 6 additions & 1 deletion info.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ services:

### Configuration

{% if installed %}
### Breaking Changes
Replaced option **switch** with **switchenabled**, because it gave some users an error
{% endif %}

To use the `monitor_docker` in your installation, add the following to your `configuration.yaml` file:

```yaml
Expand Down Expand Up @@ -82,7 +87,7 @@ monitor_docker:
| rename | dictionary (Optional) | Dictionary of containers to rename. Default no renaming. |
| sensorname | string (Optional) | Sensor string to format the name used in Home Assistant. Defaults to `{name} {sensor}`, where `{name}` is the container name and `{sensor}` is e.g. Memory, Status, Network speed Up |
| switchname | string (optional) | Switch string to format the name used in Home Assistant. Defaults to `{name}`, where `{name}` is the container name. |
| switch | boolean (Optional) | Enable/Disable the switch entity for all containers. Default is enabled. |
| switchenabled | boolean (Optional) | Enable/Disable the switch entity for all containers. Default is enabled. |

| Monitored Conditions | Description | Unit |
| --------------------------------- | ------------------------------- | ----- |
Expand Down

0 comments on commit 6ebc174

Please sign in to comment.