mirror of
https://github.com/esphome/esphome.git
synced 2026-10-14 10:12:52 +00:00
29 lines
726 B
Python
29 lines
726 B
Python
import esphome.codegen as cg
|
|
from esphome.components import sensor
|
|
from esphome.types import ConfigType
|
|
|
|
from .. import (
|
|
HOME_ASSISTANT_IMPORT_SCHEMA,
|
|
final_validate_entity_id,
|
|
homeassistant_ns,
|
|
setup_home_assistant_entity,
|
|
)
|
|
|
|
DEPENDENCIES = ["api"]
|
|
|
|
HomeassistantSensor = homeassistant_ns.class_(
|
|
"HomeassistantSensor", sensor.Sensor, cg.Component
|
|
)
|
|
|
|
CONFIG_SCHEMA = sensor.sensor_schema(HomeassistantSensor, accuracy_decimals=1).extend(
|
|
HOME_ASSISTANT_IMPORT_SCHEMA
|
|
)
|
|
|
|
FINAL_VALIDATE_SCHEMA = final_validate_entity_id
|
|
|
|
|
|
async def to_code(config: ConfigType) -> None:
|
|
var = await sensor.new_sensor(config)
|
|
await cg.register_component(var, config)
|
|
setup_home_assistant_entity(var, config)
|