Wifi scan results (#1605)

* adding a scan results wifi text sensor

* Code comment

* Adding scan results to test

* Removing redundant call

* linting

* Better method to update wifi info

Co-authored-by: Otto Winter <otto@otto-winter.com>

* Getting loop back

At least for now.

* Trying out suggestion again

* Applying cr suggestions

Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
Gustavo Ambrozio
2021-09-22 01:44:09 -10:00
committed by GitHub
parent fd836e982e
commit 8bebf138ee
5 changed files with 43 additions and 0 deletions
@@ -5,6 +5,7 @@ from esphome.const import (
CONF_BSSID,
CONF_ID,
CONF_IP_ADDRESS,
CONF_SCAN_RESULTS,
CONF_SSID,
CONF_MAC_ADDRESS,
)
@@ -15,6 +16,9 @@ wifi_info_ns = cg.esphome_ns.namespace("wifi_info")
IPAddressWiFiInfo = wifi_info_ns.class_(
"IPAddressWiFiInfo", text_sensor.TextSensor, cg.Component
)
ScanResultsWiFiInfo = wifi_info_ns.class_(
"ScanResultsWiFiInfo", text_sensor.TextSensor, cg.PollingComponent
)
SSIDWiFiInfo = wifi_info_ns.class_("SSIDWiFiInfo", text_sensor.TextSensor, cg.Component)
BSSIDWiFiInfo = wifi_info_ns.class_(
"BSSIDWiFiInfo", text_sensor.TextSensor, cg.Component
@@ -30,6 +34,11 @@ CONFIG_SCHEMA = cv.Schema(
cv.GenerateID(): cv.declare_id(IPAddressWiFiInfo),
}
),
cv.Optional(CONF_SCAN_RESULTS): text_sensor.TEXT_SENSOR_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(ScanResultsWiFiInfo),
}
).extend(cv.polling_component_schema("60s")),
cv.Optional(CONF_SSID): text_sensor.TEXT_SENSOR_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(SSIDWiFiInfo),
@@ -62,3 +71,4 @@ async def to_code(config):
await setup_conf(config, CONF_SSID)
await setup_conf(config, CONF_BSSID)
await setup_conf(config, CONF_MAC_ADDRESS)
await setup_conf(config, CONF_SCAN_RESULTS)