2019-04-17 12:06:00 +02:00
|
|
|
import esphome.codegen as cg
|
|
|
|
import esphome.config_validation as cv
|
|
|
|
from esphome.components import sensor, spi
|
2021-06-03 03:49:56 +02:00
|
|
|
from esphome.const import (
|
|
|
|
DEVICE_CLASS_TEMPERATURE,
|
|
|
|
STATE_CLASS_MEASUREMENT,
|
|
|
|
UNIT_CELSIUS,
|
|
|
|
)
|
2019-04-17 12:06:00 +02:00
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
max6675_ns = cg.esphome_ns.namespace("max6675")
|
|
|
|
MAX6675Sensor = max6675_ns.class_(
|
|
|
|
"MAX6675Sensor", sensor.Sensor, cg.PollingComponent, spi.SPIDevice
|
|
|
|
)
|
2019-04-17 12:06:00 +02:00
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
CONFIG_SCHEMA = (
|
2021-06-03 03:49:56 +02:00
|
|
|
sensor.sensor_schema(
|
2022-02-17 22:27:20 +01:00
|
|
|
MAX6675Sensor,
|
2021-08-01 12:21:32 +02:00
|
|
|
unit_of_measurement=UNIT_CELSIUS,
|
|
|
|
accuracy_decimals=1,
|
|
|
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
|
|
|
state_class=STATE_CLASS_MEASUREMENT,
|
2021-06-03 03:49:56 +02:00
|
|
|
)
|
2021-03-07 20:03:16 +01:00
|
|
|
.extend(cv.polling_component_schema("60s"))
|
|
|
|
.extend(spi.spi_device_schema())
|
|
|
|
)
|
2019-04-17 12:06:00 +02:00
|
|
|
|
|
|
|
|
2021-05-24 10:58:29 +02:00
|
|
|
async def to_code(config):
|
2022-02-17 22:27:20 +01:00
|
|
|
var = await sensor.new_sensor(config)
|
2021-05-24 10:58:29 +02:00
|
|
|
await cg.register_component(var, config)
|
|
|
|
await spi.register_spi_device(var, config)
|