Skip to content

Commit

Permalink
Merge pull request #125 from astrandb/AirLinkMoreSensors
Browse files Browse the repository at this point in the history
Add more sensors to AirLink
  • Loading branch information
astrandb authored Jan 17, 2024
2 parents f6d90ef + bf427f7 commit 77d8e8e
Showing 4 changed files with 40 additions and 94 deletions.
3 changes: 3 additions & 0 deletions custom_components/weatherlink/__init__.py
Original file line number Diff line number Diff line change
@@ -489,6 +489,9 @@ def _preprocess(indata: str): # noqa: C901
outdata[tx_id][DataKey.TIMESTAMP] = sensor["data"][0]["ts"]
outdata[tx_id][DataKey.TEMP] = sensor["data"][0]["temp"]
outdata[tx_id][DataKey.HUM] = sensor["data"][0]["hum"]
outdata[tx_id][DataKey.DEWPOINT] = sensor["data"][0]["dew_point"]
outdata[tx_id][DataKey.HEAT_INDEX] = sensor["data"][0]["heat_index"]
outdata[tx_id][DataKey.WET_BULB] = sensor["data"][0]["wet_bulb"]
outdata[tx_id][DataKey.PM_1] = sensor["data"][0]["pm_1"]
outdata[tx_id][DataKey.PM_2P5] = sensor["data"][0]["pm_2p5"]
outdata[tx_id][DataKey.PM_10] = sensor["data"][0]["pm_10"]
17 changes: 16 additions & 1 deletion custom_components/weatherlink/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ class WLBinarySensorDescription(BinarySensorEntityDescription):
entity_category=EntityCategory.DIAGNOSTIC,
# exclude_api_ver=(ApiVersion.API_V1,),
# exclude_data_structure=(2,),
aux_sensors=(55, 56),
aux_sensors=(55, 56, 323, 326),
),
)

@@ -109,6 +109,21 @@ async def async_setup_entry(
sensor["tx_id"],
)
)
if sensor["tx_id"] is None:
for description in SENSOR_TYPES:
if sensor["sensor_type"] in description.aux_sensors and (
coordinator.data[sensor["lsid"]].get(description.tag)
is not None
):
aux_entities.append(
WLSensor(
coordinator,
hass,
config_entry,
description,
sensor["lsid"],
)
)

async_add_entities(entities + aux_entities)

112 changes: 20 additions & 92 deletions custom_components/weatherlink/sensor.py
Original file line number Diff line number Diff line change
@@ -250,7 +250,7 @@ class WLSensorDescription(SensorEntityDescription):
suggested_display_precision=1,
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
state_class=SensorStateClass.MEASUREMENT,
aux_sensors=(55,),
aux_sensors=(55, 323, 326),
),
WLSensorDescription(
key="WindChill",
@@ -272,7 +272,7 @@ class WLSensorDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
aux_sensors=(55,),
aux_sensors=(55, 323, 326),
),
WLSensorDescription(
key="WetBulb",
@@ -285,7 +285,7 @@ class WLSensorDescription(SensorEntityDescription):
entity_registry_enabled_default=False,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(2,),
aux_sensors=(55,),
aux_sensors=(55, 323, 326),
),
WLSensorDescription(
key="ThwIndex",
@@ -342,12 +342,7 @@ class WLSensorDescription(SensorEntityDescription):
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
12,
25,
),
exclude_data_structure=(2, 10, 12, 25),
),
WLSensorDescription(
key="SolarPanelVolt",
@@ -359,12 +354,7 @@ class WLSensorDescription(SensorEntityDescription):
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
12,
25,
),
exclude_data_structure=(2, 10, 12, 25),
),
WLSensorDescription(
key="SupercapVolt",
@@ -376,12 +366,7 @@ class WLSensorDescription(SensorEntityDescription):
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
12,
25,
),
exclude_data_structure=(2, 10, 12, 25),
),
*(
WLSensorDescription(
@@ -393,10 +378,7 @@ class WLSensorDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfPressure.CBAR,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
10,
23,
),
exclude_data_structure=(10, 23),
aux_sensors=(56,),
)
for numb in range(1, 4 + 1)
@@ -410,10 +392,7 @@ class WLSensorDescription(SensorEntityDescription):
suggested_display_precision=1,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
10,
23,
),
exclude_data_structure=(10, 23),
aux_sensors=(56,),
)
for numb in range(1, 2 + 1)
@@ -427,10 +406,7 @@ class WLSensorDescription(SensorEntityDescription):
suggested_display_precision=1,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
10,
23,
),
exclude_data_structure=(10, 23),
)
for numb in range(3, 4 + 1)
),
@@ -444,11 +420,7 @@ class WLSensorDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
23,
),
exclude_data_structure=(2, 10, 23),
aux_sensors=(56,),
)
for numb in range(1, 4 + 1)
@@ -463,10 +435,7 @@ class WLSensorDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
10,
23,
),
exclude_data_structure=(10, 23),
)
for numb in range(1, 7 + 1)
),
@@ -480,10 +449,7 @@ class WLSensorDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
10,
23,
),
exclude_data_structure=(10, 23),
)
for numb in range(1, 4 + 1)
),
@@ -496,10 +462,7 @@ class WLSensorDescription(SensorEntityDescription):
translation_key=f"hum_extra_{numb}",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
exclude_data_structure=(
10,
23,
),
exclude_data_structure=(10, 23),
)
for numb in range(1, 7 + 1)
),
@@ -512,12 +475,7 @@ class WLSensorDescription(SensorEntityDescription):
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
12,
25,
),
exclude_data_structure=(2, 10, 12, 25),
aux_sensors=(323, 326),
),
WLSensorDescription(
@@ -529,12 +487,7 @@ class WLSensorDescription(SensorEntityDescription):
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
12,
25,
),
exclude_data_structure=(2, 10, 12, 25),
aux_sensors=(323, 326),
),
WLSensorDescription(
@@ -546,12 +499,7 @@ class WLSensorDescription(SensorEntityDescription):
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
12,
25,
),
exclude_data_structure=(2, 10, 12, 25),
aux_sensors=(323, 326),
),
WLSensorDescription(
@@ -562,12 +510,7 @@ class WLSensorDescription(SensorEntityDescription):
suggested_display_precision=1,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
12,
25,
),
exclude_data_structure=(2, 10, 12, 25),
aux_sensors=(323, 326),
),
WLSensorDescription(
@@ -578,12 +521,7 @@ class WLSensorDescription(SensorEntityDescription):
suggested_display_precision=1,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
12,
25,
),
exclude_data_structure=(2, 10, 12, 25),
aux_sensors=(323, 326),
),
WLSensorDescription(
@@ -594,12 +532,7 @@ class WLSensorDescription(SensorEntityDescription):
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
12,
25,
),
exclude_data_structure=(2, 10, 12, 25),
aux_sensors=(323, 326),
),
WLSensorDescription(
@@ -610,12 +543,7 @@ class WLSensorDescription(SensorEntityDescription):
suggested_display_precision=1,
state_class=SensorStateClass.MEASUREMENT,
exclude_api_ver=(ApiVersion.API_V1,),
exclude_data_structure=(
2,
10,
12,
25,
),
exclude_data_structure=(2, 10, 12, 25),
aux_sensors=(323, 326),
),
)
2 changes: 1 addition & 1 deletion custom_components/weatherlink/translations/en.json
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@
},
"sensor": {
"aqi_nowcast_val": {
"name": "AQI Nowcast"
"name": "Air quality index Nowcast"
},
"bar_trend": {
"name": "Pressure trend",

0 comments on commit 77d8e8e

Please sign in to comment.