Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions homeassistant/components/purpleair/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ class PurpleAirSensorEntityDescription(
SENSOR_DESCRIPTIONS = [
PurpleAirSensorEntityDescription(
key="humidity",
name="Humidity",
device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda sensor: sensor.humidity,
),
PurpleAirSensorEntityDescription(
key="pm0.3_count_concentration",
name="PM0.3 count concentration",
translation_key="pm0_3_count_concentration",
entity_registry_enabled_default=False,
icon="mdi:blur",
native_unit_of_measurement=CONCENTRATION_PARTICLES_PER_100_MILLILITERS,
Expand All @@ -67,7 +66,7 @@ class PurpleAirSensorEntityDescription(
),
PurpleAirSensorEntityDescription(
key="pm0.5_count_concentration",
name="PM0.5 count concentration",
translation_key="pm0_5_count_concentration",
entity_registry_enabled_default=False,
icon="mdi:blur",
native_unit_of_measurement=CONCENTRATION_PARTICLES_PER_100_MILLILITERS,
Expand All @@ -76,7 +75,7 @@ class PurpleAirSensorEntityDescription(
),
PurpleAirSensorEntityDescription(
key="pm1.0_count_concentration",
name="PM1.0 count concentration",
translation_key="pm1_0_count_concentration",
entity_registry_enabled_default=False,
icon="mdi:blur",
native_unit_of_measurement=CONCENTRATION_PARTICLES_PER_100_MILLILITERS,
Expand All @@ -85,15 +84,14 @@ class PurpleAirSensorEntityDescription(
),
PurpleAirSensorEntityDescription(
key="pm1.0_mass_concentration",
name="PM1.0 mass concentration",
device_class=SensorDeviceClass.PM1,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda sensor: sensor.pm1_0,
),
PurpleAirSensorEntityDescription(
key="pm10.0_count_concentration",
name="PM10.0 count concentration",
translation_key="pm10_0_count_concentration",
entity_registry_enabled_default=False,
icon="mdi:blur",
native_unit_of_measurement=CONCENTRATION_PARTICLES_PER_100_MILLILITERS,
Expand All @@ -102,15 +100,14 @@ class PurpleAirSensorEntityDescription(
),
PurpleAirSensorEntityDescription(
key="pm10.0_mass_concentration",
name="PM10.0 mass concentration",
device_class=SensorDeviceClass.PM10,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda sensor: sensor.pm10_0,
),
PurpleAirSensorEntityDescription(
key="pm2.5_count_concentration",
name="PM2.5 count concentration",
translation_key="pm2_5_count_concentration",
entity_registry_enabled_default=False,
icon="mdi:blur",
native_unit_of_measurement=CONCENTRATION_PARTICLES_PER_100_MILLILITERS,
Expand All @@ -119,15 +116,14 @@ class PurpleAirSensorEntityDescription(
),
PurpleAirSensorEntityDescription(
key="pm2.5_mass_concentration",
name="PM2.5 mass concentration",
device_class=SensorDeviceClass.PM25,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda sensor: sensor.pm2_5,
),
PurpleAirSensorEntityDescription(
key="pm5.0_count_concentration",
name="PM5.0 count concentration",
translation_key="pm5_0_count_concentration",
entity_registry_enabled_default=False,
icon="mdi:blur",
native_unit_of_measurement=CONCENTRATION_PARTICLES_PER_100_MILLILITERS,
Expand All @@ -136,15 +132,14 @@ class PurpleAirSensorEntityDescription(
),
PurpleAirSensorEntityDescription(
key="pressure",
name="Pressure",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=UnitOfPressure.MBAR,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda sensor: sensor.pressure,
),
PurpleAirSensorEntityDescription(
key="rssi",
name="RSSI",
translation_key="rssi",
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
Expand All @@ -154,15 +149,14 @@ class PurpleAirSensorEntityDescription(
),
PurpleAirSensorEntityDescription(
key="temperature",
name="Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda sensor: sensor.temperature,
),
PurpleAirSensorEntityDescription(
key="uptime",
name="Uptime",
translation_key="uptime",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
device_class=SensorDeviceClass.DURATION,
Expand All @@ -171,9 +165,9 @@ class PurpleAirSensorEntityDescription(
value_fn=lambda sensor: sensor.uptime,
),
PurpleAirSensorEntityDescription(
# This sensor is an air quality index for VOCs. More info at https://github.com/home-assistant/core/pull/84896
key="voc",
name="VOC",
device_class=SensorDeviceClass.AQI,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the device class removed? The comment above and removing the device class doesn't add up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I think of it, it does not make sense to remove it, because AQI isn't bound to one index. #96062

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was the conclusion in the PR referenced in the code comment above. Hence, removing the device class as a result of the discussion in that PR doesn't make sense without further explanation.

For the future, please don't mix adding entity translations and removing other entity features. If we need to remove something, that should be a separate PR and discussion.

Also, please start filling out the PR template correctly. Adding entity translations isn't code quality. It's a new feature. And fill out the rest of the check boxes as appropriate. Eg, have you followed the PR checklist, there's no code commented etc.

translation_key="voc_aqi",
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda sensor: sensor.voc,
),
Expand Down
31 changes: 31 additions & 0 deletions homeassistant/components/purpleair/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,36 @@
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
}
},
"entity": {
"sensor": {
"pm0_3_count_concentration": {
"name": "PM0.3 count concentration"
},
"pm0_5_count_concentration": {
"name": "PM0.5 count concentration"
},
"pm1_0_count_concentration": {
"name": "PM1.0 count concentration"
},
"pm10_0_count_concentration": {
"name": "PM10.0 count concentration"
},
"pm2_5_count_concentration": {
"name": "PM2.5 count concentration"
},
"pm5_0_count_concentration": {
"name": "PM5.0 count concentration"
},
"rssi": {
"name": "RSSI"
},
"uptime": {
"name": "Uptime"
},
"voc_aqi": {
"name": "Volatile organic compounds air quality index"
}
}
}
}