[max31856] Use cv.frequency as validator (#7212)

This commit is contained in:
Jesse Hills 2024-08-07 15:47:46 +12:00 committed by GitHub
parent 73f786c606
commit 9b0c2234d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import sensor, spi from esphome.components import sensor, spi
import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_MAINS_FILTER, CONF_MAINS_FILTER,
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TEMPERATURE,
@ -15,8 +15,8 @@ MAX31856Sensor = max31856_ns.class_(
MAX31865ConfigFilter = max31856_ns.enum("MAX31856ConfigFilter") MAX31865ConfigFilter = max31856_ns.enum("MAX31856ConfigFilter")
FILTER = { FILTER = {
"50HZ": MAX31865ConfigFilter.FILTER_50HZ, 50: MAX31865ConfigFilter.FILTER_50HZ,
"60HZ": MAX31865ConfigFilter.FILTER_60HZ, 60: MAX31865ConfigFilter.FILTER_60HZ,
} }
CONFIG_SCHEMA = ( CONFIG_SCHEMA = (
@ -29,8 +29,8 @@ CONFIG_SCHEMA = (
) )
.extend( .extend(
{ {
cv.Optional(CONF_MAINS_FILTER, default="60HZ"): cv.enum( cv.Optional(CONF_MAINS_FILTER, default="60Hz"): cv.All(
FILTER, upper=True, space="" cv.frequency, cv.enum(FILTER, int=True)
), ),
} }
) )