Bonjour Claude,
your code seems to work, no compile error reported:
The next step with this code would be to add parameters to it like this :
{% set angle = states('sensor.sinope_technologies_lm4110_zb_angle') | float(0) %}
{% set x_min = 110 %}
{% set x_max = 406 %}
{% set delta = 46 %}
{% set low = 10 %}
{% set high = 80 %}
And replace the numerical values in the formula with these parameters. This make the formula easier to understand and easier to change from a 10-80 to 5-95 gauge. However, I have not been able to get these parameters to be used successfully yet.
Iâll further investigate and let you know. If you are successfull on your side, please let me know.
I think Iâll add to my code an âoffsetâ parameter to account for the âgapâ seen in between the actual reading (73%) of the gauge and the calculated value (70%). This will ensure that the calculated value is the same than the actual reading.
after some experiments, here is the updated code, with âparametersâ, including the âoffsetâ, to take into account differences in the gauge reading and reported value:
# Calculates propane tank % according to value returned by Sinope device (for R3D 10-80 gauge)
template:
- trigger:
- platform: time_pattern
hours: "/5"
- sensor:
- name: "Tank remaining level"
unit_of_measurement: "%"
icon: mdi:propane-tank
state: >
{% set angle = states('sensor.sinope_technologies_lm4110_zb_angle') | float %}
{% set x_min = 110 | float %}
{% set x_max = 406 | float %}
{% set delta = 46 | float %}
{% set low = 10 | float %}
{% set high = 80 | float %}
{% set offset = 3 | float %}
{% if ((delta <= angle) and (70 >= angle)) %}
{{ (((delta-110)/(x_max-x_min)*(high-low))+low+offset) | round(0) }}
{% elif ((0 <= angle) and (delta > angle)) %}
{{ (((angle)+360-x_min)/(x_max-x_min)*(high-low)+low+offset) | round(0) }}
{% else %}
{{ (((angle)-x_min)/(x_max-x_min)*(high-low)+low+offset) | round(0) }}
{% endif %}
With your offset I get 63% and my gauge is at 62%. So I think that the offset is not linear.
But ±1 % is a good start.
It would be very interesting if we can merge both 10-80 and 5-95 in the same template so the user will have just to set on parameter, gauge type 5-95 or 10-80. No need to touch other parameters.
Regarding the âoffsetâ parameter, I suggest that it has to be set by the user, to âcompensateâ the accuracy of the gauge vs sensor. In my case, a value of 3 gives an exact reading while in your case, the offset should be 2.
Regarding the code, I just found out a quick fix to be made:
replace:
{% if ((delta <= angle) and (70 >= angle)) %}
{{ (((delta-110)/(x_max-x_min)*(high-low))+low+offset) | round(0) }}
by:
{% if ((delta <= angle) and (70 >= angle)) %}
{{ (((delta-x_min)/(x_max-x_min)*(high-low))+low+offset) | round(0) }}
Ok for the quick fix. I also think that we should have a separate parameter for gauge type and offset value until we found a fix for the offset value depending on the tank level.
Iâve updated my readme.md to add the setup for gauge type and offset parameter setting as parameter outside the calculation template.
For ânetworkâ I have tried the literal name of the location as well, as well as no network entry at all (I only have one location) but no joy.
My logs:
This error originated from a custom integration.
Logger: homeassistant.setup
Source: custom_components/neviweb130/__init__.py:243
Integration: neviweb130 (documentation)
First occurred: September 8, 2023 at 6:38:17 PM (1 occurrences)
Last logged: September 8, 2023 at 6:38:17 PM
Error during setup of component neviweb130
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 288, in _async_setup_component
result = await task
^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/neviweb130/__init__.py", line 136, in setup
data = Neviweb130Data(hass_config[DOMAIN])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/neviweb130/__init__.py", line 168, in __init__
self.neviweb130_client = Neviweb130Client(username, password, network, network2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/neviweb130/__init__.py", line 198, in __init__
self.__get_network()
File "/config/custom_components/neviweb130/__init__.py", line 243, in __get_network
raw_res = requests.get(LOCATIONS_URL + self._account, headers=self._headers,
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str
Iâm trying to read attribute 19 (tankSize) from cluster 0xff01 that is liste on your attributes table for the Calypso but using zigbee2mqtt and it says that this is an unsupported attribute for calypso
The others attribute are reading fine, i,e drConfigWaterTempMin is at 45 and I can adjust it
Est-ce que ca vaut la peine dâessayer dâajuster cet attribut Ă la bonne valeur ou je me casse la tĂȘte pour rien?
I already made a PR to update the zcl of z2m (cluster.ts) in zigbee-herdsman earlier this week. Its not merged yet. Koen asked me to test it before by editing the cluster.ts file on my installation. I did and now im able to poll this attribute from the dev console but it only returns that its not supported, I was expecting to get a number from 1 to 4. It worked fine when I added drConfigWaterTempMin a few months ago, so I dont understand why tankSize is not.
Hi everybody, is there any documentation somewhere to understand how to template the wifi thermostats with no local gateways ? I tried many solutions, nothing works yet. I am connected to the neviweb API, but I donât how to see the thermostats / sensors⊠I think I am struggling with the naming convention in the yaml file essentially.
The connection to neviweb works though: