mirror of
https://github.com/esphome/esphome.git
synced 2025-10-19 10:13:49 +01:00
add sim800l diagnostics (#3136)
This commit is contained in:
committed by
GitHub
parent
a13a1225b7
commit
113232ebb6
33
esphome/components/sim800l/sensor.py
Normal file
33
esphome/components/sim800l/sensor.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import sensor
|
||||
from esphome.const import (
|
||||
DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_DECIBEL_MILLIWATT,
|
||||
)
|
||||
from . import CONF_SIM800L_ID, Sim800LComponent
|
||||
|
||||
DEPENDENCIES = ["sim800l"]
|
||||
|
||||
CONF_RSSI = "rssi"
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
cv.GenerateID(CONF_SIM800L_ID): cv.use_id(Sim800LComponent),
|
||||
cv.Optional(CONF_RSSI): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_DECIBEL_MILLIWATT,
|
||||
accuracy_decimals=0,
|
||||
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
sim800l_component = await cg.get_variable(config[CONF_SIM800L_ID])
|
||||
|
||||
if CONF_RSSI in config:
|
||||
sens = await sensor.new_sensor(config[CONF_RSSI])
|
||||
cg.add(sim800l_component.set_rssi_sensor(sens))
|
Reference in New Issue
Block a user