Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions homeassistant/components/switch/broadlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
CONF_COMMAND_OFF, CONF_COMMAND_ON, CONF_FRIENDLY_NAME, CONF_HOST, CONF_MAC,
CONF_SWITCHES, CONF_TIMEOUT, CONF_TYPE)
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle
from homeassistant.util import Throttle, slugify
from homeassistant.util.dt import utcnow

REQUIREMENTS = ['broadlink==0.8.0']
Expand Down Expand Up @@ -187,7 +187,7 @@ class BroadlinkRMSwitch(SwitchDevice):

def __init__(self, name, friendly_name, device, command_on, command_off):
"""Initialize the switch."""
self.entity_id = ENTITY_ID_FORMAT.format(name)
self.entity_id = ENTITY_ID_FORMAT.format(slugify(name))
self._name = friendly_name
self._state = False
self._command_on = b64decode(command_on) if command_on else None
Expand Down Expand Up @@ -257,7 +257,7 @@ class BroadlinkSP1Switch(BroadlinkRMSwitch):

def __init__(self, friendly_name, device):
"""Initialize the switch."""
super().__init__(friendly_name, device, None, None)
super().__init__(friendly_name, friendly_name, device, None, None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the related issue, this should be slugified before used for the entity_id. Probably do that in the parent.

self._command_on = 1
self._command_off = 0

Expand Down Expand Up @@ -313,7 +313,7 @@ class BroadlinkMP1Slot(BroadlinkRMSwitch):

def __init__(self, friendly_name, device, slot, parent_device):
"""Initialize the slot of switch."""
super().__init__(friendly_name, device, None, None)
super().__init__(friendly_name, friendly_name, device, None, None)
self._command_on = 1
self._command_off = 0
self._slot = slot
Expand Down