JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
957 stars 80 forks source link

Clear deprecated constants on 2025.1 #492

Closed Nemesis24 closed 6 months ago

Nemesis24 commented 6 months ago

Description

SUPPORT_TONES was used from tapo_control, this is a deprecated constant which will be removed in HA Core 2025.1. Use SirenEntityFeature.TONES instead, please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues SUPPORT_TURN_OFF was used from tapo_control, this is a deprecated constant which will be removed in HA Core 2025.1. Use SirenEntityFeature.TURN_OFF instead, please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues SUPPORT_TURN_ON was used from tapo_control, this is a deprecated constant which will be removed in HA Core 2025.1. Use SirenEntityFeature.TURN_ON instead, please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues SUPPORT_DURATION was used from tapo_control, this is a deprecated constant which will be removed in HA Core 2025.1. Use SirenEntityFeature.DURATION instead, please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues

Reproduction Steps

go to system logs

Expected behavior

don't have this advertissement

If applicable, add error logs.

No response

Device Firmware

1.3.11

Integration Version

5.4.12

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

pi

Search for similar issues

Yes

Additional information

No response

tjorim commented 6 months ago

Not sure what you mean by 'advertissement' but it's a warning. Please note this is related to Home Assistant version 2024.1.0b0! (Please mention this next time @Nemesis24)

Furthermore these deprecations are also present:

ChristophCaina commented 6 months ago

nearly all "SUPPORT_" features for different devices (Climate, Camera, Cover, Vaccuum, ....) will be depricated with 2024.1.

With one the first beta releases, an Error was logged, but this was due to a missing dependency - since 0b1 or 0b2 only a deprication warning will be shown.

After a short look into the code, I guess, the following lines needs to be changed:

from homeassistant.components.camera import (
    SUPPORT_ON_OFF,
    SUPPORT_STREAM,
    Camera,
)

to:

from homeassistant.components.camera import  CameraEntityFeature, Camera
    def supported_features(self):
        if self._enable_stream:
            return SUPPORT_STREAM | SUPPORT_ON_OFF
        else:
            return SUPPORT_ON_OFF

to:

    def supported_features(self):
        if self._enable_stream:
            return CameraEntityFeature.STREAM | CameraEntityFeature.ON_OFF
        else:
            return CameraEntityFeature.ON_OFF

<--- these are just examples, because I do not have TAPO installed and can't test any change. Also, I am not sure, if other files might be affected, too...

here's the blog post about the deprication:

https://developers.home-assistant.io/blog/2022/04/02/support-constants-deprecation https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation