Skip to content

Commit

Permalink
Drop platform config support
Browse files Browse the repository at this point in the history
  • Loading branch information
pnbruckner committed Nov 26, 2024
1 parent 34acae3 commit eec2f9a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 60 deletions.
35 changes: 1 addition & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ After it has been downloaded you will need to restart Home Assistant.

### Versions

This custom integration supports HomeAssistant versions 2023.4.0 or newer.
This custom integration supports HomeAssistant versions 2024.8.3 or newer.

## Services

Expand All @@ -99,38 +99,5 @@ Key | Optional | Description
`name` | yes | Name of the sensor. Default is `Illuminance`.
`scan_interval` | yes | Update interval. Minimum is 30 seconds. Default is 5 minutes.

## Converting from `platform` configuration

In previous versions, configuration was done under `sensor`.
This is now deprecated and will generate a warning at startup.
It should be converted to the new `illuminance` format as described above.
Or simply remove it and add the sensor(s) via the UI.

Here is an example of the old format:

```yaml
sensor:
- platform: illuminance
entity_id: weather.home_forecast
fallback: 5
mode: normal
name: Weather-Based Sun Illuminance
scan_interval:
minutes: 10
```
This is the equivalent configuration in the new format:
```yaml
illuminance:
- unique_id: 1
entity_id: weather.home_forecast
fallback: 5
mode: normal
name: Weather-Based Sun Illuminance
scan_interval:
minutes: 10
```
## Releases Before 2.1.0
See https://github.com/pnbruckner/homeassistant-config/blob/master/docs/illuminance.md.
28 changes: 2 additions & 26 deletions custom_components/illuminance/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import voluptuous as vol

from homeassistant.components.sensor import (
DOMAIN as SENSOR_DOMAIN,
PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA,
SensorDeviceClass,
SensorEntity,
Expand Down Expand Up @@ -50,7 +49,6 @@
CONF_ENTITY_ID,
CONF_MODE,
CONF_NAME,
CONF_PLATFORM,
CONF_SCAN_INTERVAL,
LIGHT_LUX,
STATE_UNAVAILABLE,
Expand All @@ -69,7 +67,7 @@
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback, EntityPlatform
from homeassistant.helpers.event import async_track_state_change_event
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.helpers.typing import ConfigType
import homeassistant.util.dt as dt_util
from homeassistant.util.hass_dict import HassKey

Expand Down Expand Up @@ -167,11 +165,7 @@ class IlluminanceSensorEntityDescription(SensorEntityDescription): # type: igno
scan_interval: timedelta | None = None


def _sensor(
config: ConfigType,
unique_id: str | None = None,
scan_interval: timedelta | None = None,
) -> Entity:
def _sensor(config: ConfigType, unique_id: str, scan_interval: timedelta) -> Entity:
"""Create entity to add."""
weather_entity = config.get(CONF_ENTITY_ID)
fallback = cast(
Expand Down Expand Up @@ -202,24 +196,6 @@ def _sensor(
return IlluminanceSensor(entity_description)


async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up sensors."""
_LOGGER.warning(
"%s: %s under %s is deprecated. Move to %s:",
CONF_PLATFORM,
DOMAIN,
SENSOR_DOMAIN,
DOMAIN,
)

async_add_entities([_sensor(config)], True)


async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
Expand Down

0 comments on commit eec2f9a

Please sign in to comment.