mirror of
https://github.com/esphome/esphome.git
synced 2024-12-04 04:28:19 +01:00
5c65f9f9ad
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
39 lines
1 KiB
Python
39 lines
1 KiB
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import sensor, uart
|
|
from esphome.const import (
|
|
CONF_ID,
|
|
STATE_CLASS_MEASUREMENT,
|
|
UNIT_METER,
|
|
ICON_ARROW_EXPAND_VERTICAL,
|
|
)
|
|
|
|
CODEOWNERS = ["@netmikey"]
|
|
DEPENDENCIES = ["uart"]
|
|
|
|
hrxlmaxsonarwr_ns = cg.esphome_ns.namespace("hrxl_maxsonar_wr")
|
|
HrxlMaxsonarWrComponent = hrxlmaxsonarwr_ns.class_(
|
|
"HrxlMaxsonarWrComponent", sensor.Sensor, cg.Component, uart.UARTDevice
|
|
)
|
|
|
|
CONFIG_SCHEMA = (
|
|
sensor.sensor_schema(
|
|
unit_of_measurement=UNIT_METER,
|
|
icon=ICON_ARROW_EXPAND_VERTICAL,
|
|
accuracy_decimals=3,
|
|
state_class=STATE_CLASS_MEASUREMENT,
|
|
)
|
|
.extend(
|
|
{
|
|
cv.GenerateID(): cv.declare_id(HrxlMaxsonarWrComponent),
|
|
}
|
|
)
|
|
.extend(uart.UART_DEVICE_SCHEMA)
|
|
)
|
|
|
|
|
|
async def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
await cg.register_component(var, config)
|
|
await sensor.register_sensor(var, config)
|
|
await uart.register_uart_device(var, config)
|