rvdbreemen / OTGW-firmware

A ESP8266 devkit firmware for the Nodoshop version of the Opentherm Gateway (OTGW)
MIT License
145 stars 34 forks source link

Status_master expected to be numeric by Home Assistant #234

Closed FrankBakkerNl closed 2 months ago

FrankBakkerNl commented 7 months ago

Not sure if this is correct repo for this issue, please let me know if not.

I have got my OTGW hooked up to Home Assistant via MQTT, everything seems to be working fine, except for the Home Assistant shows errors in the logs.

My take on this is that thius is because in thge mqtt payload the status_master has a "unit_of_measurement": ""

and HA then requires it to be numeric, while the data is not

Error in HA log

2023-11-30 21:12:29.578 ERROR (MainThread) [homeassistant.components.mqtt.models] Exception raised when updating state of sensor.opentherm_gateway_otgw_otgw_status_master, topic: 'OTGW/value/otgw-C82B96202DA8/status_master' with payload: b'C----W--'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 588, in state
    numerical_value = int(value)
                      ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: **'C----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 591, in state
    numerical_value = float(value)
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: 'C----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 779, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 879, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 820, in _async_generate_attributes
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 785, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 595, in state
    raise ValueError(
ValueError: Sensor sensor.opentherm_gateway_otgw_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: 'C----W--' (<class 'str'>)

mqtt payload homeassistant/sensor/otgw-C82B96202DA8/status_master/config

{
  "avty_t": "OTGW/value/otgw-C82B96202DA8",
  "dev": {
    "identifiers": "otgw-C82B96202DA8",
    "manufacturer": "Schelte Bron",
    "model": "otgw-nodo",
    "name": "OpenTherm Gateway (OTGW)",
    "sw_version": "0.10.2+50c3ed2 (14-03-2023)"
  },
  "uniq_id": "otgw-C82B96202DA8-status_master",
  "name": "OTGW_Status_Master",
  "stat_t": "OTGW/value/otgw-C82B96202DA8/status_master",
  **"unit_of_measurement": "",**
  "value_template": "{{ value }}"
}
FrankBakkerNl commented 6 months ago

It seems like this is a duplictae of #217 which is fixed. Do I need to build the new binary miself or is it available for download aomewhere? (Nodo Shop seems to have an old version online for download)

rvdbreemen commented 5 months ago

Hi @FrankBakkerNl

Sorry for the delay, there is a beta/release candidate. I can share it with you to test.

The fix is also just uploading a single file mqttha.cfg

Btw it's a warning in HA log. It doesn't break the integration.

Let me know if you want to test the next binary release?

Robert

Ps. Sorry for the late response.

FrankBakkerNl commented 5 months ago

Yea sure I'll test the binary

rvdbreemen commented 2 months ago

@FrankBakkerNl sorry, I never pointed you to the binary, here you go: https://github.com/rvdbreemen/OTGW-firmware/actions/runs/8545594129/artifacts/1382759830

FrankBakkerNl commented 2 months ago

Tnx, I found the config file here and updated that manually, that also did the trick. Works great btw, tnx for the awesome work

rvdbreemen commented 2 months ago

Thanks for reporting back that it fixed your issue.

In the next release this config is included by default.