Skip to content

Commit

Permalink
Replace deprecated device class constants (JohNan#37)
Browse files Browse the repository at this point in the history
* Replace deprecated device class constants

* Update hacs.json
  • Loading branch information
JohNan authored Jan 13, 2023
1 parent 95934aa commit ba201dc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ A custom component designed for [Home Assistant](https://www.home-assistant.io)
- Well A5 Air Purifier

### Install with HACS (recommended)
Do you you have [HACS][hacs] installed? Just search for Electrolux Wellbeing and install it direct from HACS. HACS will keep track of updates and you can easly upgrade this component to latest version.
Do you you have [HACS][hacs] installed? Just search for Electrolux Wellbeing and install it direct from HACS. HACS will keep track of updates and you can easily upgrade this integration to latest version.

### Installation
### Manual Installation

1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`).
2. If you do not have a `custom_components` directory (folder) there, you need to create it.
Expand Down
39 changes: 22 additions & 17 deletions custom_components/wellbeing/api.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
"""Sample API Client."""
import json
from datetime import datetime, timedelta

import asyncio
import logging
import socket
from datetime import datetime, timedelta
from enum import Enum
from typing import Union

import aiohttp
import async_timeout

from custom_components.wellbeing.const import SENSOR, FAN, BINARY_SENSOR
from homeassistant.components.binary_sensor import DEVICE_CLASS_CONNECTIVITY
from homeassistant.const import TEMP_CELSIUS, PERCENTAGE, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_CO2, \
DEVICE_CLASS_HUMIDITY, CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_BILLION
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.const import TEMP_CELSIUS, PERCENTAGE, CONCENTRATION_PARTS_PER_MILLION, \
CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER

TIMEOUT = 10
RETRIES = 3
Expand Down Expand Up @@ -113,7 +111,7 @@ def _create_entities(data):
name="eCO2",
attr='ECO2',
unit=CONCENTRATION_PARTS_PER_MILLION,
device_class=DEVICE_CLASS_CO2
device_class=SensorDeviceClass.CO2
),
ApplianceSensor(
name=f"{FILTER_TYPE[data.get('FilterType_1', 0)]} Life",
Expand Down Expand Up @@ -145,20 +143,20 @@ def _create_entities(data):
name="CO2",
attr='CO2',
unit=CONCENTRATION_PARTS_PER_MILLION,
device_class=DEVICE_CLASS_CO2
device_class=SensorDeviceClass.CO2
),
]

common_entities = [
ApplianceFan(
name="Fan Speed",
attr='Fanspeed'
attr='Fanspeed',
),
ApplianceSensor(
name="Temperature",
attr='Temp',
unit=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE
device_class=SensorDeviceClass.TEMPERATURE
),
ApplianceSensor(
name="TVOC",
Expand All @@ -167,21 +165,27 @@ def _create_entities(data):
),
ApplianceSensor(
name="PM1",
attr='PM1'
attr='PM1',
unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
device_class=SensorDeviceClass.PM1
),
ApplianceSensor(
name="PM2.5",
attr='PM2_5'
attr='PM2_5',
unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
device_class=SensorDeviceClass.PM25
),
ApplianceSensor(
name="PM10",
attr='PM10'
attr='PM10',
unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
device_class=SensorDeviceClass.PM10
),
ApplianceSensor(
name="Humidity",
attr='Humidity',
unit=PERCENTAGE,
device_class=DEVICE_CLASS_HUMIDITY
device_class=SensorDeviceClass.HUMIDITY
),
ApplianceSensor(
name="Mode",
Expand All @@ -198,15 +202,16 @@ def _create_entities(data):
ApplianceBinary(
name="Connection State",
attr='connectionState',
device_class=DEVICE_CLASS_CONNECTIVITY
device_class=BinarySensorDeviceClass.CONNECTIVITY
),
ApplianceBinary(
name="Status",
attr='status'
),
ApplianceBinary(
name="Safety Lock",
attr='SafetyLock'
attr='SafetyLock',
device_class=BinarySensorDeviceClass.LOCK
)
]

Expand Down
4 changes: 1 addition & 3 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"name": "Electrolux Wellbeing",
"hacs": "1.6.0",
"domains": ["binary_sensor", "sensor", "fan"],
"iot_class": "Cloud Polling",
"homeassistant": "2021.5.0"
"homeassistant": "2021.12.0"
}

0 comments on commit ba201dc

Please sign in to comment.