-
Notifications
You must be signed in to change notification settings - Fork 726
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
[Help] Converting Zlinky_TIC quirk to a quirk v2 #3453
Comments
Ok, I figured out that if you don't define any entities in the quirkbuilder you get the message
After adding the sensor sensor the message is replaced
|
The assoicated PR is #3456 |
You don't need to add any custom entities for a v2 quirk. It's just a debug message stating that none were added. (
QuirkBuilder(LIXEE, "ZLinky_TIC")
.replaces(ZLinkyTICMetering)
.replaces(ZLinkyTICManufacturerCluster)
.add_to_registry()
) But I see you already have that in your PR. |
@TheJulianJES, thanks. I'm actually trying to extend the quirk as I convert it. The basic just works. Maybe you can help with the following. Right now, I can't get around string I fetch from the zlinky_tic device being processed by the stringify mechanism. I'm not quite sure, because the code base is new to me, but it feels like an issue in the ZHA sensor handling. I'm adding a sensor like that: .sensor(
Basic.AttributeDefs.model.name,
Basic.cluster_id,
fallback_name="Model",
) The atrribute type is type=t.LimitedCharString(32) but the type seems to be ignore in ZHA sensor handling and eventully I get this error. 2024-10-28 10:38:43.407 ERROR (MainThread) [homeassistant.components.sensor] Error adding entity sensor.lixee_zlinky_tic_model for domain sensor with platform zha
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 595, in _async_add_entities
await coro
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 909, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1366, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1005, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
self.__async_calculate_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1011, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 542, in state
value = self.native_value
^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/zha/sensor.py", line 136, in native_value
return self.entity_data.entity.native_value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/zha/application/platforms/sensor/__init__.py", line 249, in native_value
return self.formatter(raw_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/zha/application/platforms/sensor/__init__.py", line 271, in formatter
float(value * self._multiplier) / self._divisor, self._decimals
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: 'ZLinky_TIC' |
String sensors aren't currently supported, you can specify the sensor class via device_class, but only numeric and timestamps are currently supported. I don't even see a SensorDeviceClass that would correspond to a string. That said, why are you trying to add a sensor for the model name? |
Thanks, that makes more sense with what I see. I'm not trying to make a sensor from the model name. That was just an example. There are other ZCL attributes which report a string. For example, I get the current tarif applied by electricity supplier as a string from ZLIinky. I also have it as an integer and I can apply an enum on that one. |
Thanks for all your work here! I am looking forward to using this for extracting the French EDF Tempo tariff information for today and tomorrow. That would be a good use case for strings, btw, since these are present in the TIC information as strings. An enum could work around this but then all user interfaces have to translate the enum to a string. |
This is issue is request for help. I hope we can have a conversation about how to convert an existing quirk into a quirk v2. I could not find existing issue related to that. I also hope documenting my steps here can help other developper during their conversion.
Following the PR #3448, @TheJulianJES suggested to convert the quirk for Zlinky_TIC into a quirk v2.
The proposed modification is to replace the signature for Fw 14.0 with
Looking at the log it does not look like it's working
Although in HA it looks like the device is associated with my quirks v2:
So I'm a little confused by that line in the logs:
The text was updated successfully, but these errors were encountered: