mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-30 01:38:27 +02:00
Add internal_temperature component (#4330)
* 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>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user