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

ValueError Inverter State #6

Closed
mieschc opened this issue May 4, 2023 · 23 comments
Closed

ValueError Inverter State #6

mieschc opened this issue May 4, 2023 · 23 comments
Assignees

Comments

@mieschc
Copy link

mieschc commented May 4, 2023

Moin Stefan,

after the core update yesterday evening Home Assistant lost connection to my Piko 20 Inverter. I had following error message in the logs:


Logger: homeassistant.components.sensor
Source: components/sensor/init.py:583
Integration: Sensor (documentation, issues)
First occurred: 10:06:34 (2 occurrences)
Last logged: 10:06:34

Error adding entities for domain sensor with platform kostal_piko
Error while setting up kostal_piko platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 579, in state
numerical_value = int(value)
ValueError: invalid literal for int() with base 10: 'Input (MPP)'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 846, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state
if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 583, in state
raise ValueError(
ValueError: Sensor sensor.kostal_piko_inverter_state has device class None, state class measurement unit None and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: Input (MPP) (<class 'str'>)


After a restart Home Assistant picked only up one updated value and stopped fetching values again.

I changed now the state class of Piko Inverter to None to fix the problem temporarly and it is working again. I now get updated values again, but the values are interuppted. See screenshots.

After change:
interuppted values

inverter state

Before change:
values before

Do you have any better solution for it?

Brgds

Christopher

@dinomyte76
Copy link

I do have the same issue. A solution for this would be awesome. Loving this integration a lot and until the core update yesterday it was running like a "cat"!!!

@dinomyte76
Copy link

@mieschc May i ask where did you set the state class of Piko Inverter to None in HA? Thanks in advance!

@mieschc
Copy link
Author

mieschc commented May 5, 2023

@dinomyte76 Go to folder custom components / kostal piko and open const.py. There you find the entry for the Inverter state.

As mentioned the fetching ist interupted but Energy Dashboard is still working.

Screenshot_2023-05-05-22-33-22-47_40deb401b9ffe8e1df2f1cc5ba480b12~3

@leon2908
Copy link

leon2908 commented May 8, 2023

I do have the same issue.

@2121-4
Copy link

2121-4 commented May 16, 2023

I have the same issue.

@dinomyte76
Copy link

I tried a bunch of things in the last days (also tried other integrations) and yesterday evening - after upgrading to latest core version - i gave this integration another try, but this time i commented the complete part of the inverter state which @mieschc suggested.
It seems to work as before now. At least i do not have anymore interuptions.

grafik

grafik

@2121-4
Copy link

2121-4 commented May 16, 2023

@dinomyte76
Did your fix. Seems it works again 🥇
grafik

@mieschc
Copy link
Author

mieschc commented May 16, 2023

@dinomyte76 good idea. Did the same now and working as well.

@leon2908
Copy link

@dinomyte76 sadly still not working for me :(
I commentet all your lines out but still only get one update after a restart HA.

@dinomyte76
Copy link

@leon2908 Hmm dunno. Do you see anything suspicious in your home-assistatnt.log file?

@leon2908
Copy link

@dinomyte76 I´m sorry, I only tryed to comment out the lines and after a restart of HA I saw the number only update once I shut down HA an loaded a Backup from yesterday.

@leon2908
Copy link

Any Update with the new HA Operating System 10.2 or the Core Update 2023.5.4 ?

@mieschc
Copy link
Author

mieschc commented May 30, 2023

@leon2908 Looks not like Stefan ist still maintaining this Integration. I suggest to try commenting the Inverter state again. Maybe you Just missed one line last time.

@leon2908
Copy link

leon2908 commented May 31, 2023

I give this one another go and now I get the following Error in the Log and had the same Error again.. @mieschc :(

Bildschirmfoto 2023-05-31 um 19 10 01

Logger: homeassistant.components.sensor
Source: components/sensor/init.py:583
Integration: Sensor ([documentation
First occurred: 18:56:51 (2 occurrences)
Last logged: 18:56:51

Error adding entities for domain sensor with platform kostal_piko
Error while setting up kostal_piko platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 579, in state
numerical_value = int(value)
ValueError: invalid literal for int() with base 10: 'Input (MPP)'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 845, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state
if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 583, in state
raise ValueError(
ValueError: Sensor sensor.kostal_piko_inverter_state has device class None, state class measurement unit None and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: Input (MPP) (<class 'str'>)

@mieschc
Copy link
Author

mieschc commented Jun 7, 2023

@leon2908 Sorry, I cannot help you really. I did the same like you. Did you restart Home Assistant after the change?

@mangan62
Copy link

mangan62 commented Jun 12, 2023

grafik

Thanks for your work. Worked well up to version HA 2023.4 with Piko 20. after update 2023.5 the integration stopped working. Error message at Inverter State. After deleting # Inverter state and restart HA, it works again without Inverter State

@sla89 sla89 self-assigned this Jul 21, 2023
@sla89
Copy link
Owner

sla89 commented Jul 21, 2023

Sorry folks, for some reason I do not get any notification when a new issue is created.

I will take a look at the issue in the evening and come up with a solution. Maybe you can be my testers, since I do not have this kind of Kostal inverter.

This should be the new way the sensor should be defined (according to the documentation):

    KostalPikoSensorEntityDescription(
        description=SensorEntityDescription(
            key="kostal_piko_inverter_state",
            name="Kostal PIKO Inverter State",
            device_class=None,
            state_class=SensorDeviceClass.ENUM,
            native_unit_of_measurement=None,
            icon="mdi:power-plug",
            options=[
                "Off",
                "Idle",
                "Starting",
                "Input (MPP)",
                "Input (limited)"
            ]),
        dxs_id=16780032,
        formatter=KostalPikoFormatter.format_inverter_state
    ),

if it does not work, I will release a new version with the following configuration for the inverter state sensor as it seems to work:

    KostalPikoSensorEntityDescription(
        description=SensorEntityDescription(
            key="kostal_piko_inverter_state",
            name="Kostal PIKO Inverter State",
            device_class=None,
            state_class=None,
            native_unit_of_measurement=None,
            icon="mdi:power-plug"),
        dxs_id=16780032,
        formatter=KostalPikoFormatter.format_inverter_state
    ),

BTW I have changed my mail notifications, maybe someone of you can create another dummy issue so
that I can check that I receive mails for new issues now... I am so sorry guys.

@mieschc
Copy link
Author

mieschc commented Jul 22, 2023

Moin Stefan,

unfo I am traveling abroud until October and have only limited access to my HA Installation. If I have a chance to test it, I will do, but hopefully someone else is faster.

@sla89
Copy link
Owner

sla89 commented Jul 22, 2023

I can also just release a new version that does what is mentioned here as the working solution. I will go for that approach.

@sla89
Copy link
Owner

sla89 commented Jul 22, 2023

I have just release a new version with the fix. Please give it another try - I hope it solves your issues. Otherwise feel free to open the bug again. :) Thanks to @mieschc for providing the fix and testing my email notification settings 👯

@sla89 sla89 closed this as completed Jul 22, 2023
@mangan62
Copy link

Sorry folks, for some reason I do not get any notification when a new issue is created.

I will take a look at the issue in the evening and come up with a solution. Maybe you can be my testers, since I do not have this kind of Kostal inverter.

This should be the new way the sensor should be defined (according to the documentation):

    KostalPikoSensorEntityDescription(
        description=SensorEntityDescription(
            key="kostal_piko_inverter_state",
            name="Kostal PIKO Inverter State",
            device_class=None,
            state_class=SensorDeviceClass.ENUM,
            native_unit_of_measurement=None,
            icon="mdi:power-plug",
            options=[
                "Off",
                "Idle",
                "Starting",
                "Input (MPP)",
                "Input (limited)"
            ]),
        dxs_id=16780032,
        formatter=KostalPikoFormatter.format_inverter_state
    ),

if it does not work, I will release a new version with the following configuration for the inverter state sensor as it seems to work:

    KostalPikoSensorEntityDescription(
        description=SensorEntityDescription(
            key="kostal_piko_inverter_state",
            name="Kostal PIKO Inverter State",
            device_class=None,
            state_class=None,
            native_unit_of_measurement=None,
            icon="mdi:power-plug"),
        dxs_id=16780032,
        formatter=KostalPikoFormatter.format_inverter_state
    ),

BTW I have changed my mail notifications, maybe someone of you can create another dummy issue so that I can check that I receive mails for new issues now... I am so sorry guys.

@mangan62
Copy link

Thanks. the second option works. the first gives an error: ValueError: Sensor sensor.kostal_piko_inverter_state is providing enum options, but is missing the enum device clas
have a nice weekend

@sla89
Copy link
Owner

sla89 commented Jul 22, 2023

The second option is part of the latest release. Thank you for testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants