mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-06 04:48:27 +02:00
hydreon_rgxx - add resolution option (#6077)
Co-authored-by: functionpointer <suspendfunction@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_MODEL,
|
||||
CONF_MOISTURE,
|
||||
CONF_RESOLUTION,
|
||||
CONF_TEMPERATURE,
|
||||
DEVICE_CLASS_PRECIPITATION_INTENSITY,
|
||||
DEVICE_CLASS_PRECIPITATION,
|
||||
@@ -14,7 +15,7 @@ from esphome.const import (
|
||||
ICON_THERMOMETER,
|
||||
)
|
||||
|
||||
from . import RGModel, HydreonRGxxComponent
|
||||
from . import RGModel, RG15Resolution, HydreonRGxxComponent
|
||||
|
||||
UNIT_INTENSITY = "intensity"
|
||||
UNIT_MILLIMETERS = "mm"
|
||||
@@ -37,11 +38,18 @@ RG_MODELS = {
|
||||
# 1.100 - https://rainsensors.com/wp-content/uploads/sites/3/2021/03/2021.03.11-rg-9_instructions.pdf
|
||||
# 1.200 - https://rainsensors.com/wp-content/uploads/sites/3/2022/03/2022.02.17-rev-1.200-rg-9_instructions.pdf
|
||||
}
|
||||
SUPPORTED_SENSORS = {
|
||||
|
||||
RG15_RESOLUTION = {
|
||||
"low": RG15Resolution.FORCE_LOW,
|
||||
"high": RG15Resolution.FORCE_HIGH,
|
||||
}
|
||||
|
||||
SUPPORTED_OPTIONS = {
|
||||
CONF_ACC: ["RG_15"],
|
||||
CONF_EVENT_ACC: ["RG_15"],
|
||||
CONF_TOTAL_ACC: ["RG_15"],
|
||||
CONF_R_INT: ["RG_15"],
|
||||
CONF_RESOLUTION: ["RG_15"],
|
||||
CONF_MOISTURE: ["RG_9"],
|
||||
CONF_TEMPERATURE: ["RG_9"],
|
||||
CONF_DISABLE_LED: ["RG_9"],
|
||||
@@ -57,7 +65,7 @@ PROTOCOL_NAMES = {
|
||||
|
||||
|
||||
def _validate(config):
|
||||
for conf, models in SUPPORTED_SENSORS.items():
|
||||
for conf, models in SUPPORTED_OPTIONS.items():
|
||||
if conf in config:
|
||||
if config[CONF_MODEL] not in models:
|
||||
raise cv.Invalid(
|
||||
@@ -75,6 +83,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
upper=True,
|
||||
space="_",
|
||||
),
|
||||
cv.Optional(CONF_RESOLUTION): cv.enum(RG15_RESOLUTION, upper=False),
|
||||
cv.Optional(CONF_ACC): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_MILLIMETERS,
|
||||
accuracy_decimals=2,
|
||||
@@ -139,6 +148,9 @@ async def to_code(config):
|
||||
cg.add(var.set_sensor(sens, i))
|
||||
|
||||
cg.add(var.set_model(config[CONF_MODEL]))
|
||||
if CONF_RESOLUTION in config:
|
||||
cg.add(var.set_resolution(config[CONF_RESOLUTION]))
|
||||
|
||||
cg.add(var.set_request_temperature(CONF_TEMPERATURE in config))
|
||||
|
||||
if CONF_DISABLE_LED in config:
|
||||
|
||||
Reference in New Issue
Block a user