Skip to content

Home Assistant 20223.5.0 now throwing exception #217

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

Closed
mcc05 opened this issue May 4, 2023 · 21 comments
Closed

Home Assistant 20223.5.0 now throwing exception #217

mcc05 opened this issue May 4, 2023 · 21 comments
Assignees
Labels
bug Something isn't working

Comments

@mcc05
Copy link
Contributor

mcc05 commented May 4, 2023

As of the latest version of HA, the status string returned from OTG is throwing an exception

Logger: homeassistant.components.mqtt.models
Source: components/sensor/init.py:583
Integration: MQTT (documentation, issues)
First occurred: 06:42:09 (2631 occurrences)
Last logged: 07:40:29

Exception raised when updating state of sensor.idealboiler_status_slave, topic: 'IdealBoiler/value/idealC40/status_slave' with payload: b'-C-F----'
Exception raised when updating state of sensor.idealboiler_status_slave, topic: 'IdealBoiler/value/idealC40' with payload: b'online'
Exception raised when updating state of sensor.idealboiler_status_master, topic: 'IdealBoiler/value/idealC40' with payload: b'online'
Exception raised when updating state of sensor.idealboiler_status_master, topic: 'IdealBoiler/value/idealC40/status_master' with payload: b'-D---W--'
Exception raised when updating state of sensor.idealboiler_status_slave, topic: 'IdealBoiler/value/idealC40/status_slave' with payload: b'--------'
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: '-D---W--'

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

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 270, in process_write_state_requests
entity.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.idealboiler_status_master has device class None, state class None unit and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: -D---W-- (<class 'str'>)

@mcc05
Copy link
Contributor Author

mcc05 commented May 4, 2023

Done a change for merge to stop this

@brhahlen
Copy link
Contributor

brhahlen commented May 4, 2023

Can confirm and can also confirm that the changes made in #218 (at least on the lines 136 and 137) stop these errors.

@serrj-sv
Copy link

serrj-sv commented May 8, 2023

@rvdbreemen Could you please release binaries with fix

@rvdbreemen
Copy link
Owner

Trying to fix CI pipeline... anyone any ideas what it fails, help would be welcome ;-)

@serrj-sv I want to fix the pipeline, but you can download mqttha.cfg from the data folder in the dev branch and upload it manually.

@brhahlen
Copy link
Contributor

@rvdbreemen From a quick look at the error in the CI Pipeline, it kind of looks like you are running into this breaking change: arduino/arduino-cli#2085

I gathered this from the following lines:
Writing config file: Config File "arduino-cli" Not Found in "[/home/runner/.arduino15]"

Apparently, you now need to explicitly ggive a --config-file flag in the arduino-cli command, as it does not automatically pick up the config file from the current directory anymore.
Docs: https://github.com/arduino/arduino-cli/blob/master/docs/UPGRADING.md#arduino-cli-doesnt-lookup-anymore-in-the-current-directory-for-configuration-file

Does that make sense?

@rvdbreemen
Copy link
Owner

Ben,
That makes a lot of sense, I missed that completely.
Thanks for the PR,
Robert

@brhahlen
Copy link
Contributor

Ben,
That makes a lot of sense, I missed that completely.
Thanks for the PR,
Robert

You're welcome!
Glad I have been able to give a little bit back :)

@rvdbreemen
Copy link
Owner

I looked into the issue myself last night. It turns out that the 2023.5.0 is breaking not just my integration, a lot of integrations broke of this change in HA Core. I have seen this before, this will also mean that 2023.5.x will most likely fix this in the Core side, but it's good to clean up the mqttha.cfg integration a bit.

Please keep upgrading HA yourself too, it could also be that it will fix itself in 2-3 weeks time because they fix core.

Seriously we have seen this many times before with HA, move fast break often and fix. The HA core project is really good at this ;-)

@euro2
Copy link

euro2 commented May 31, 2023

Not sure but this is in the logs. Didnt check logs for weeks. Occurances rising fast after a reboot.

`Logger: homeassistant.components.mqtt.models
Source: components/sensor/init.py:583
Integration: MQTT (documentation, issues)
First occurred: 10:40:21 (34 occurrences)
Last logged: 10:42:07

Exception raised when updating state of sensor.otgw_status_master, topic: 'OTGW/value/otgw-xxxx/status_master' with payload: b'-----W--'
Exception raised when updating state of sensor.otgw_status_slave, topic: 'OTGW/value/otgw-xxxx/status_slave' with payload: b'--------'
Exception raised when updating state of sensor.otgw_status_slave, topic: 'OTGW/value/otgw-xxxx' with payload: b'online'
Exception raised when updating state of sensor.otgw_status_master, topic: 'OTGW/value/otgw-xxxx' with payload: b'online'
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: '-----W--'

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

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 270, in process_write_state_requests
entity.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.otgw_status_master has device class None, state class None unit and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: -----W-- (<class 'str'>)
`

@rik1984
Copy link

rik1984 commented Jun 11, 2023

Same issue here, I'm running HA 2023.5.2 where it is not fixed yet. I don't understand the instructions referring to post #218, Should I update the OTGW firmware, or manually change something in OTGW?

Sorry in case this is a beginner question, I just try to get rid of my HA error logs, and this one has count of 56269 occurences since 48 hours already

@rvdbreemen
Copy link
Owner

@rik1984 the fix needs to be validated, but you can download the mqttha.cfg from the dev branch on github.

You can find it right here: https://github.com/rvdbreemen/OTGW-firmware/blob/dev/data/mqttha.cfg
If you download it, you can manually to the ESP using the file explorer.

I have already download the beta build here:
https://github.com/rvdbreemen/OTGW-firmware/suites/12881434620/artifacts/695010907

If you have some time, then please test it for me. Worst thing that could happen is that it works, and then I can release it.

@rik1984
Copy link

rik1984 commented Jun 12, 2023

Thanks for your guidance. I have manually deleted mqttha.cfg from the file system and uploaded the new version. I can confirm that it solves the issue

@t0mas
Copy link

t0mas commented Sep 20, 2023

Tested with Home Assistant 2023.8.4 and it solves the error issue in the log. So far all sensors etc seem to work as normal.

@borft
Copy link

borft commented Sep 22, 2023

Tested on HA 2023.9.2, works like a charm, otgw sensors look well and stable. (I manually swapped out mqttha.cfg btw.

@mikeg-de
Copy link

mikeg-de commented Sep 28, 2023

I still face the issue spamming logs like crazy. @rik1984 when deleting and upliading a new mqttha.cfg, did you changed anything in particular?

I am using:

Home Assistant 2023.9.3
Supervisor 2023.09.2
Operating System 10.5
Frontend 20230911.0 - latest

Logger: homeassistant.components.mqtt.models
Source: components/sensor/__init__.py:593
Integration: MQTT ([documentation](https://www.home-assistant.io/integrations/mqtt), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+mqtt%22))
First occurred: 26 September 2023 at 10:52:28 (73848 occurrences)
Last logged: 13:27:38

Exception raised when updating state of sensor.otgw_status_slave, topic: 'OTGW/value/otgw-485519150FBB/status_slave' with payload: b'-C------'
Exception raised when updating state of sensor.otgw_status_master, topic: 'OTGW/value/otgw-485519150FBB/status_master' with payload: b'-D---W--'
Exception raised when updating state of sensor.otgw_status_slave, topic: 'OTGW/value/otgw-485519150FBB/status_slave' with payload: b'--------'
Exception raised when updating state of sensor.otgw_status_slave, topic: 'OTGW/value/otgw-485519150FBB' with payload: b'online'
Exception raised when updating state of sensor.otgw_status_master, topic: 'OTGW/value/otgw-485519150FBB' with payload: b'online'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 586, in state
    numerical_value = int(value)
                      ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '-D---W--'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 589, in state
    numerical_value = float(value)
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: '-D---W--'

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 305, in process_write_state_requests
    entity.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 730, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 771, in _async_generate_attributes
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 593, in state
    raise ValueError(
ValueError: Sensor sensor.otgw_status_master has device class 'None', state class 'None' unit '' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '-D---W--' (<class 'str'>)

@rik1984
Copy link

rik1984 commented Sep 28, 2023

I still face the issue spamming logs like crazy. @rik1984 when deleting and upliading a new mqttha.cfg, did you changed anything in particular?

No I didn't do anything special, only following the instructions. I'm now running HA9.1 ans will without issues (not sure whether the mqttha.cfg file has been updated along with my HA updates or whether it is still in the version I changed it to, to be honest.

@borft
Copy link

borft commented Sep 28, 2023

I still face the issue spamming logs like crazy. @rik1984 when deleting and upliading a new mqttha.cfg, did you changed anything in particular?

No I didn't do anything special, only following the instructions. I'm now running HA9.1 ans will without issues (not sure whether the mqttha.cfg file has been updated along with my HA updates or whether it is still in the version I changed it to, to be honest.

well, the mqttha.cfg file is on the otgw right? (more specifically on the wifi microcontroller on the otgw), so I don't see how that would be affected by updating ha ;)

@rik1984
Copy link

rik1984 commented Sep 28, 2023

I still face the issue spamming logs like crazy. @rik1984 when deleting and upliading a new mqttha.cfg, did you changed anything in particular?

No I didn't do anything special, only following the instructions. I'm now running HA9.1 ans will without issues (not sure whether the mqttha.cfg file has been updated along with my HA updates or whether it is still in the version I changed it to, to be honest.

well, the mqttha.cfg file is on the otgw right? (more specifically on the wifi microcontroller on the otgw), so I don't see how that would be affected by updating ha ;)

You are right indeed ;) so no changes done there since

@dbrb2
Copy link

dbrb2 commented Dec 7, 2023

I came across this issue today
I am running 0.10.2+50c3ed2

I have replaced the mqtt config file as suggested, however the MQTT status fields, after a power cycle, still show:

-D---W--

And the HA logs:

`Logger: homeassistant.components.mqtt.models
Source: components/mqtt/models.py:305
Integration: MQTT (documentation, issues)
First occurred: 00:36:03 (10 occurrences)
Last logged: 00:59:20

Exception raised when updating state of sensor.otgw_status_slave, topic: 'OTGW/value/otgw-2CF43257D8CD/status_slave' with payload: b'--------'
Exception raised when updating state of sensor.otgw_status_master, topic: 'OTGW/value/otgw-2CF43257D8CD/status_master' with payload: b'CD---W--'
Exception raised when updating state of sensor.otgw_status_slave, topic: 'OTGW/value/otgw-2CF43257D8CD/status_slave' with payload: b'-C-F----'
Exception raised when updating state of sensor.otgw_status_slave, topic: 'OTGW/value/otgw-2CF43257D8CD' with payload: b'online'
Exception raised when updating state of sensor.otgw_status_master, topic: 'OTGW/value/otgw-2CF43257D8CD' with payload: b'online'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 616, in state
numerical_value = int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '-D---W--'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 619, in state
numerical_value = float(value)
^^^^^^^^^^^^
ValueError: could not convert string to float: '-D---W--'

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

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 305, in process_write_state_requests
entity.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 745, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 845, in _async_write_ha_state
state, attr = self._async_generate_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in _async_generate_attributes
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 751, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 623, in state
raise ValueError(
ValueError: Sensor sensor.otgw_status_master has device class 'None', state class 'None' unit '' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '-D---W--' (<class 'str'>)
`

Any ideas?

@rvdbreemen
Copy link
Owner

I will have a look into this soon. To see how to fix this. It is most likely a fix to the mqttha.cfg templates that is needed.

@rvdbreemen
Copy link
Owner

There is a working mqttha.cfg in the devbranch and there are dev binaries candidate available.

Issue does not break HA integration.

But I do need to release this. 🙈

@rvdbreemen rvdbreemen added the bug Something isn't working label Apr 7, 2024
@rvdbreemen rvdbreemen self-assigned this Apr 7, 2024
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
Status: No status
Development

No branches or pull requests

10 participants