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

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

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
3 changes: 2 additions & 1 deletion homeassistant/components/climate/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging

from homeassistant.util import convert
from homeassistant.components.climate import ClimateDevice
from homeassistant.components.climate import (ENTITY_ID_FORMAT, ClimateDevice)
from homeassistant.const import (
TEMP_FAHRENHEIT,
TEMP_CELSIUS,
Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion homeassistant/components/cover/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
import logging

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

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
3 changes: 2 additions & 1 deletion homeassistant/components/light/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging

from homeassistant.components.light import (
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, ENTITY_ID_FORMAT, Light)
from homeassistant.const import (STATE_OFF, STATE_ON)
from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
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
3 changes: 2 additions & 1 deletion homeassistant/components/lock/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
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)
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
2 changes: 2 additions & 0 deletions homeassistant/components/sensor/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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)

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
3 changes: 2 additions & 1 deletion homeassistant/components/switch/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging

from homeassistant.util import convert
from homeassistant.components.switch import SwitchDevice
from homeassistant.components.switch import (SwitchDevice, ENTITY_ID_FORMAT)
from homeassistant.const import (STATE_OFF, STATE_ON)
from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
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