Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning after Home Assistant upgrade to 2021.12.0 #658

Open
pabsi opened this issue Dec 12, 2021 · 12 comments
Open

Warning after Home Assistant upgrade to 2021.12.0 #658

pabsi opened this issue Dec 12, 2021 · 12 comments
Labels
bug Something isn't working

Comments

@pabsi
Copy link

pabsi commented Dec 12, 2021

The problem

After upgrading Home Assistant to the latest version (2021.12.0) I now get this in the logs when starting up the server:

WARNING (MainThread) [homeassistant.helpers.entity] Entity switch.tuyaswitch (<class 'custom_components.localtuya.switch.LocaltuyaSwitch'>) implements device_state_attributes. Please report it to the custom component author.

Environment

  • Localtuya version: Latest release as of today (tag v.3.2.4)
  • Last working localtuya version (if known and relevant): n/a/
  • Home Assistant Core version: 2021.12.0
  • [] Are you using the Home Assistant Tuya Cloud component ?
  • [] Are you using the Tuya App in parallel ?
@pabsi pabsi added the bug Something isn't working label Dec 12, 2021
@pabsi
Copy link
Author

pabsi commented Dec 12, 2021

Definitely not a bug, but can't remove the label :(
sorry

@Mangomc
Copy link

Mangomc commented Dec 13, 2021

Sorry but its defintely the old wrong way you use, so its a bug, Please read the changelog of the new build. And look at https://www.home-assistant.io/docs/configuration/templating/ the yellow warning. Also ur readme is wrong in the way u tell to use the device attributes.

Avoid using states.sensor.temperature.state, instead use states('sensor.temperature')

It now should be that way:

platform: template
  sensors:
    washing_machine_current:
        friendly_name_template: "Waschmaschine Stromstärke"
        value_template: "{{ state_attr('switch.steckdose_waschmaschine', 'current') | float(0.0) }}"
        unit_of_measurement: 'mA'
        
    washing_machine_current_consumption:
        friendly_name_template: "Waschmaschine aktueller Verbrauch"
        value_template: "{{ state_attr('switch.steckdose_waschmaschine', 'current_consumption') | float(0.0) }}"
        unit_of_measurement: 'W'
        
    washing_machine_voltage:
        friendly_name_template: "Waschmaschine Volt"
        value_template: "{{ state_attr('switch.steckdose_waschmaschine', 'voltage') | float(0.0) }}"
        unit_of_measurement: 'V'

Please fix your integration, i love it :)

@pabsi
Copy link
Author

pabsi commented Dec 14, 2021

Sorry but its defintely the old wrong way you use, so its a bug, Please read the changelog of the new build. And look at https://www.home-assistant.io/docs/configuration/templating/ the yellow warning. Also ur readme is wrong in the way u tell to use the device attributes.

Avoid using states.sensor.temperature.state, instead use states('sensor.temperature')

It now should be that way:

platform: template
  sensors:
    washing_machine_current:
        friendly_name_template: "Waschmaschine Stromstärke"
        value_template: "{{ state_attr('switch.steckdose_waschmaschine', 'current') | float(0.0) }}"
        unit_of_measurement: 'mA'
        
    washing_machine_current_consumption:
        friendly_name_template: "Waschmaschine aktueller Verbrauch"
        value_template: "{{ state_attr('switch.steckdose_waschmaschine', 'current_consumption') | float(0.0) }}"
        unit_of_measurement: 'W'
        
    washing_machine_voltage:
        friendly_name_template: "Waschmaschine Volt"
        value_template: "{{ state_attr('switch.steckdose_waschmaschine', 'voltage') | float(0.0) }}"
        unit_of_measurement: 'V'

Please fix your integration, i love it :)

Hey, I am not sure whether you are talking to me, or the author of the intergration 😅

I definitely used the custom component the right way as stated in the README (via config flow). It all worked good and without issues until HA updated to 2021.12.

Hope the author fixes this (I'd be happy to contribute with a PR, but I am not familiar enough with neither custom components nor python stuff in HA)

@Mangomc
Copy link

Mangomc commented Dec 14, 2021

To the author of the integration but i dont want to create a new issue with the same context

@sefininio
Copy link

sefininio commented Dec 15, 2021

I am seeing the same issue on HA 2021.12.1 with latest local tuya 3.2.4
Seems like device_state_attributes is deprecated and should be removed and replaced with extra_state_attributes

@danielbrunt57
Copy link

Here is the full log message I see:

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:549
First occurred: 3:45:55 PM (7 occurrences)
Last logged: 3:49:38 PM

Entity switch.plug_1 (<class 'custom_components.localtuya.switch.LocaltuyaSwitch'>) implements device_state_attributes. Please report it to the custom component author.
Entity switch.plug_3 (<class 'custom_components.localtuya.switch.LocaltuyaSwitch'>) implements device_state_attributes. Please report it to the custom component author.

FEI, the browser_mod custom component has the same new issue:

Entity sensor.browser_mod_e11f3fb6_438343f8 (<class 'custom_components.browser_mod.sensor.BrowserModSensor'>) implements device_state_attributes. Please report it to the custom component author.
Entity media_player.browser_mod_e11f3fb6_438343f8 (<class 'custom_components.browser_mod.media_player.BrowserModPlayer'>) implements device_state_attributes. Please report it to the custom component author.
Entity light.browser_mod_e11f3fb6_438343f8 (<class 'custom_components.browser_mod.light.BrowserModLight'>) implements device_state_attributes. Please report it to the custom component author.

@danielbrunt57
Copy link

danielbrunt57 commented Dec 17, 2021

The fix is on it's way:. sefininio@bfba2d7

image

You can make the fix yourself. Edit config/custom_components/localtuya/switch.py line # 51

@jouster1974
Copy link

above fix didnt seem to work...

@danielbrunt57
Copy link

Don't know what to say. It worked fine for me...the warning is gone.

image

@cihantok
Copy link

Düzeltme yolda:. jsBlackBelt@ bfba2d7

resim

Düzeltmeyi kendiniz yapabilirsiniz. config/custom_components/localtuya/switch.py ​​satır # 51'i düzenleyin

This worked for me thank you

@blavak68
Copy link

Düzeltme yolda:. jsBlackBelt@ bfba2d7
resim
Düzeltmeyi kendiniz yapabilirsiniz. config/custom_components/localtuya/switch.py ​​satır # 51'i düzenleyin

This worked for me thank you

yes, this worked for me too, thx

@jeremysherriff
Copy link

Fixed in #663

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants