Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions homeassistant/components/binary_sensor/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import logging

from homeassistant.components.binary_sensor import (
BinarySensorDevice)
BinarySensorDevice, ENTITY_ID_FORMAT)
from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)

DEPENDENCIES = ['vera']

Expand All @@ -30,6 +30,7 @@ def __init__(self, vera_device, controller):
"""Initialize the binary_sensor."""
self._state = False
VeraDevice.__init__(self, vera_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)

@property
def is_on(self):
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/climate/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import logging

from homeassistant.util import convert
from homeassistant.components.climate import ClimateDevice
from homeassistant.components.climate import ClimateDevice, ENTITY_ID_FORMAT
from homeassistant.const import (
TEMP_FAHRENHEIT,
TEMP_CELSIUS,
ATTR_TEMPERATURE)

from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)

DEPENDENCIES = ['vera']

Expand All @@ -37,6 +37,7 @@ class VeraThermostat(VeraDevice, ClimateDevice):
def __init__(self, vera_device, controller):
"""Initialize the Vera device."""
VeraDevice.__init__(self, vera_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)

@property
def current_operation(self):
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/cover/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"""
import logging

from homeassistant.components.cover import CoverDevice
from homeassistant.components.cover import CoverDevice, ENTITY_ID_FORMAT
from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)

DEPENDENCIES = ['vera']

Expand All @@ -28,6 +28,7 @@ class VeraCover(VeraDevice, CoverDevice):
def __init__(self, vera_device, controller):
"""Initialize the Vera device."""
VeraDevice.__init__(self, vera_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)

@property
def current_cover_position(self):
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/light/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import logging

from homeassistant.components.light import (
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
ATTR_BRIGHTNESS, ENTITY_ID_FORMAT, Light, SUPPORT_BRIGHTNESS)
from homeassistant.const import (STATE_OFF, STATE_ON)
from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)

_LOGGER = logging.getLogger(__name__)

Expand All @@ -33,6 +33,7 @@ def __init__(self, vera_device, controller):
"""Initialize the light."""
self._state = False
VeraDevice.__init__(self, vera_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)

@property
def brightness(self):
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/lock/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"""
import logging

from homeassistant.components.lock import LockDevice
from homeassistant.components.lock import ENTITY_ID_FORMAT, LockDevice
from homeassistant.const import (STATE_LOCKED, STATE_UNLOCKED)
from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)

_LOGGER = logging.getLogger(__name__)

Expand All @@ -30,6 +30,7 @@ def __init__(self, vera_device, controller):
"""Initialize the Vera device."""
self._state = None
VeraDevice.__init__(self, vera_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)

def lock(self, **kwargs):
"""Lock the device."""
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/sensor/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
from homeassistant.const import (
TEMP_CELSIUS, TEMP_FAHRENHEIT)
from homeassistant.helpers.entity import Entity
from homeassistant.components.sensor import ENTITY_ID_FORMAT
from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)

DEPENDENCIES = ['vera']

Expand All @@ -32,6 +33,7 @@ def __init__(self, vera_device, controller):
self.current_value = None
self._temperature_units = None
VeraDevice.__init__(self, vera_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)

@property
def state(self):
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/switch/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import logging

from homeassistant.util import convert
from homeassistant.components.switch import SwitchDevice
from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchDevice
from homeassistant.const import (STATE_OFF, STATE_ON)
from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)

DEPENDENCIES = ['vera']

Expand All @@ -31,6 +31,7 @@ def __init__(self, vera_device, controller):
"""Initialize the Vera device."""
self._state = False
VeraDevice.__init__(self, vera_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)

def turn_on(self, **kwargs):
"""Turn device on."""
Expand Down
8 changes: 6 additions & 2 deletions homeassistant/components/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from requests.exceptions import RequestException

from homeassistant.util.dt import utc_from_timestamp
from homeassistant.util import convert
from homeassistant.util import (convert, slugify)
from homeassistant.helpers import discovery
from homeassistant.helpers import config_validation as cv
from homeassistant.const import (
Expand All @@ -32,6 +32,8 @@
CONF_EXCLUDE = 'exclude'
CONF_LIGHTS = 'lights'

VERA_ID_FORMAT = '{}_{}'

ATTR_CURRENT_POWER_MWH = "current_power_mwh"

VERA_DEVICES = defaultdict(list)
Expand Down Expand Up @@ -131,8 +133,10 @@ def __init__(self, vera_device, controller):
self.vera_device = vera_device
self.controller = controller

self._name = self.vera_device.name
# Append device id to prevent name clashes in HA.
self._name = self.vera_device.name + ' ' + str(vera_device.device_id)
self.vera_id = VERA_ID_FORMAT.format(
slugify(vera_device.name), vera_device.device_id)

self.controller.register(vera_device, self._update_callback)
self.update()
Expand Down