Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -3,7 +3,11 @@ from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from homeassistant.const import (
|
||||
LENGTH_KILOMETERS, LENGTH_MILES, TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_MILES,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
from . import DOMAIN as TESLA_DOMAIN, TeslaDevice
|
||||
@@ -15,13 +19,13 @@ SCAN_INTERVAL = timedelta(minutes=5)
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Tesla sensor platform."""
|
||||
controller = hass.data[TESLA_DOMAIN]['devices']['controller']
|
||||
controller = hass.data[TESLA_DOMAIN]["devices"]["controller"]
|
||||
devices = []
|
||||
|
||||
for device in hass.data[TESLA_DOMAIN]['devices']['sensor']:
|
||||
for device in hass.data[TESLA_DOMAIN]["devices"]["sensor"]:
|
||||
if device.bin_type == 0x4:
|
||||
devices.append(TeslaSensor(device, controller, 'inside'))
|
||||
devices.append(TeslaSensor(device, controller, 'outside'))
|
||||
devices.append(TeslaSensor(device, controller, "inside"))
|
||||
devices.append(TeslaSensor(device, controller, "outside"))
|
||||
else:
|
||||
devices.append(TeslaSensor(device, controller))
|
||||
add_entities(devices, True)
|
||||
@@ -39,7 +43,7 @@ class TeslaSensor(TeslaDevice, Entity):
|
||||
super().__init__(tesla_device, controller)
|
||||
|
||||
if self.type:
|
||||
self._name = '{} ({})'.format(self.tesla_device.name, self.type)
|
||||
self._name = "{} ({})".format(self.tesla_device.name, self.type)
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
@@ -65,19 +69,18 @@ class TeslaSensor(TeslaDevice, Entity):
|
||||
units = self.tesla_device.measurement
|
||||
|
||||
if self.tesla_device.bin_type == 0x4:
|
||||
if self.type == 'outside':
|
||||
if self.type == "outside":
|
||||
self.current_value = self.tesla_device.get_outside_temp()
|
||||
else:
|
||||
self.current_value = self.tesla_device.get_inside_temp()
|
||||
if units == 'F':
|
||||
if units == "F":
|
||||
self._unit = TEMP_FAHRENHEIT
|
||||
else:
|
||||
self._unit = TEMP_CELSIUS
|
||||
elif (self.tesla_device.bin_type == 0xA or
|
||||
self.tesla_device.bin_type == 0xB):
|
||||
elif self.tesla_device.bin_type == 0xA or self.tesla_device.bin_type == 0xB:
|
||||
self.current_value = self.tesla_device.get_value()
|
||||
tesla_dist_unit = self.tesla_device.measurement
|
||||
if tesla_dist_unit == 'LENGTH_MILES':
|
||||
if tesla_dist_unit == "LENGTH_MILES":
|
||||
self._unit = LENGTH_MILES
|
||||
else:
|
||||
self._unit = LENGTH_KILOMETERS
|
||||
@@ -88,7 +91,7 @@ class TeslaSensor(TeslaDevice, Entity):
|
||||
if self.tesla_device.bin_type == 0x5:
|
||||
self._unit = units
|
||||
elif self.tesla_device.bin_type in (0xA, 0xB):
|
||||
if units == 'LENGTH_MILES':
|
||||
if units == "LENGTH_MILES":
|
||||
self._unit = LENGTH_MILES
|
||||
else:
|
||||
self._unit = LENGTH_KILOMETERS
|
||||
|
||||
Reference in new issue
Block a user