mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-19 04:33:27 +02:00
ed801f7a27
* Add cpu_temperature component * Add tests * Fix formatting * Possible fix for "sensor not shown in HomeAssistant" * Rename component to internal_temperature * Update esphome/components/internal_temperature/internal_temperature.cpp Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl> * Update esphome/components/internal_temperature/internal_temperature.cpp Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl> * Update esphome/components/internal_temperature/internal_temperature.cpp Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl> * Update internal_temperature.h * Remove unique_id * Update ESP32 variant detection --------- Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
32 lines
956 B
Python
32 lines
956 B
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import sensor
|
|
from esphome.const import (
|
|
STATE_CLASS_MEASUREMENT,
|
|
UNIT_CELSIUS,
|
|
DEVICE_CLASS_TEMPERATURE,
|
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
|
)
|
|
|
|
internal_temperature_ns = cg.esphome_ns.namespace("internal_temperature")
|
|
InternalTemperatureSensor = internal_temperature_ns.class_(
|
|
"InternalTemperatureSensor", sensor.Sensor, cg.PollingComponent
|
|
)
|
|
|
|
CONFIG_SCHEMA = cv.All(
|
|
sensor.sensor_schema(
|
|
InternalTemperatureSensor,
|
|
unit_of_measurement=UNIT_CELSIUS,
|
|
accuracy_decimals=1,
|
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
|
state_class=STATE_CLASS_MEASUREMENT,
|
|
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
|
).extend(cv.polling_component_schema("60s")),
|
|
cv.only_on(["esp32", "rp2040"]),
|
|
)
|
|
|
|
|
|
async def to_code(config):
|
|
var = await sensor.new_sensor(config)
|
|
await cg.register_component(var, config)
|