mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Black
This commit is contained in:
@@ -3,8 +3,7 @@ import logging
|
||||
import math
|
||||
from typing import Optional
|
||||
|
||||
from aioesphomeapi import (
|
||||
SensorInfo, SensorState, TextSensorInfo, TextSensorState)
|
||||
from aioesphomeapi import SensorInfo, SensorState, TextSensorInfo, TextSensorState
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
@@ -14,20 +13,27 @@ from . import EsphomeEntity, esphome_state_property, platform_async_setup_entry
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistantType,
|
||||
entry: ConfigEntry, async_add_entities) -> None:
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
||||
) -> None:
|
||||
"""Set up esphome sensors based on a config entry."""
|
||||
await platform_async_setup_entry(
|
||||
hass, entry, async_add_entities,
|
||||
component_key='sensor',
|
||||
info_type=SensorInfo, entity_type=EsphomeSensor,
|
||||
state_type=SensorState
|
||||
hass,
|
||||
entry,
|
||||
async_add_entities,
|
||||
component_key="sensor",
|
||||
info_type=SensorInfo,
|
||||
entity_type=EsphomeSensor,
|
||||
state_type=SensorState,
|
||||
)
|
||||
await platform_async_setup_entry(
|
||||
hass, entry, async_add_entities,
|
||||
component_key='text_sensor',
|
||||
info_type=TextSensorInfo, entity_type=EsphomeTextSensor,
|
||||
state_type=TextSensorState
|
||||
hass,
|
||||
entry,
|
||||
async_add_entities,
|
||||
component_key="text_sensor",
|
||||
info_type=TextSensorInfo,
|
||||
entity_type=EsphomeTextSensor,
|
||||
state_type=TextSensorState,
|
||||
)
|
||||
|
||||
|
||||
@@ -52,8 +58,9 @@ class EsphomeSensor(EsphomeEntity):
|
||||
"""Return the state of the entity."""
|
||||
if math.isnan(self._state.state):
|
||||
return None
|
||||
return '{:.{prec}f}'.format(
|
||||
self._state.state, prec=self._static_info.accuracy_decimals)
|
||||
return "{:.{prec}f}".format(
|
||||
self._state.state, prec=self._static_info.accuracy_decimals
|
||||
)
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self) -> str:
|
||||
@@ -65,11 +72,11 @@ class EsphomeTextSensor(EsphomeEntity):
|
||||
"""A text sensor implementation for ESPHome."""
|
||||
|
||||
@property
|
||||
def _static_info(self) -> 'TextSensorInfo':
|
||||
def _static_info(self) -> "TextSensorInfo":
|
||||
return super()._static_info
|
||||
|
||||
@property
|
||||
def _state(self) -> Optional['TextSensorState']:
|
||||
def _state(self) -> Optional["TextSensorState"]:
|
||||
return super()._state
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user