mirror of
https://github.com/esphome/esphome.git
synced 2024-12-27 16:01:43 +01:00
better RSSI
This commit is contained in:
parent
18e3ea58b0
commit
5bcb7cf27e
2 changed files with 4 additions and 4 deletions
|
@ -5,10 +5,10 @@ from esphome.components import sensor, text_sensor, uart
|
|||
|
||||
from esphome.const import (
|
||||
DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||
UNIT_DECIBEL_MILLIWATT,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
CONF_ID,
|
||||
ENTITY_CATEGORY_NONE,
|
||||
UNIT_PERCENT,
|
||||
)
|
||||
|
||||
CODEOWNERS = ["@danielkoek"]
|
||||
|
@ -43,8 +43,8 @@ CONFIG_SCHEMA = (
|
|||
# if you want to see the rssi
|
||||
cv.Optional(CONF_LORA_RSSI): sensor.sensor_schema(
|
||||
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||
unit_of_measurement=UNIT_DECIBEL_MILLIWATT,
|
||||
accuracy_decimals=0,
|
||||
unit_of_measurement=UNIT_PERCENT,
|
||||
accuracy_decimals=1,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ void EbyteLoraComponent::loop() {
|
|||
ESP_LOGD(TAG, "VALUE: %u ", data[2]);
|
||||
ESP_LOGD(TAG, "RSSI: %#02x ", data[3]);
|
||||
if (this->rssi_sensor_ != nullptr)
|
||||
this->rssi_sensor_->publish_state(data[3]);
|
||||
this->rssi_sensor_->publish_state((data[3] / 255.0) * 100);
|
||||
if (this->message_text_sensor_ != nullptr)
|
||||
this->message_text_sensor_->publish_state("Got something");
|
||||
|
||||
|
|
Loading…
Reference in a new issue