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
[transform.map] Setting a Switch item value to NULL, shall look for -=
in a transform/.map
file, not for NULL=
.
#13777
Comments
This is an issue of the MAP transformation, moved to openhab-addons. |
Is the file switch.map your file? |
Yes, I have it under /etc/openhab/transforms. |
So why did you set this mapping rather than with NULL? |
The system throws the aforementioned exception if |
-=
in a transform/.map
file, not for NULL=
.-=
in a transform/.map
file, not for NULL=
.
"-" is what sitemap REST API map to when a state is NULL or UNDEF. I am going to confirm that by testing again. |
My items:
The part of my sitemap:
en.map contains a map for "-" but none for NULL or UNDEF:
When I open only Basic UI, I have no warning logged and the result is as expected: Now, as soon as I open Main UI, I got this warning:
The warning is repeated when opening the list of items or when opening the page of this item. Main UI is calling a REST API that calls the transformation with the state "NULL". As you can notice, the way to call transformation is done differently by Main UI and sitemap UI, sitemap UI is first converting NULL/UNDEF states into "-" before calling the transformation, Main UI does not. As a workaround until we find a proper fix, to avoid warnings whatever the used UI, the solution for MAP transformation is to add entries for "NULL" and "UNDEF" in addition to "-". For my tests, I used:
@J-N-K : please move this issue in core. |
The "problem" is in the method
|
I believe:
WDYT ? |
@openhab/core-maintainers for feedback on my analysis and my proposal. |
Note that what is done by sitemap UI is a little more than a simple replacement of NULL/UNDEF by "-": |
Use item state formatter to format input of transformation, meaning using state.format(format) instead of String.format(format, state.toString()) This was already the case in sitemap API but not in other APIs used by Main UI. Make sure to call transformation even for NULL and UNDEF states. It was not the case in one API used by Main UI. When calling transformation and state is NULL or UNDEF, do not apply format to the input value and do not replace by "-". That leans the transformation will be called with "NULL" or "UNDEF". Sitemap API was calling the transformation using a pattern containing "-". Fix openhab#4101 Also related to discussion in openhab/openhab-addons#13777 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Use item state formatter to format input of transformation, meaning using state.format(format) instead of String.format(format, state.toString()) This was already the case in sitemap API but not in other APIs used by Main UI. Make sure to call transformation even for NULL and UNDEF states. It was not the case in one API used by Main UI. When calling transformation and state is NULL or UNDEF, do not apply format to the input value and do not replace by "-". That means the transformation will be called with "NULL" or "UNDEF". Sitemap API was calling the transformation using a pattern containing "-". Fix openhab#4101 Also related to discussion in openhab/openhab-addons#13777 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Use item state formatter to format input of transformation, meaning using state.format(format) instead of String.format(format, state.toString()) This was already the case in sitemap API but not in other APIs used by Main UI. Make sure to call transformation even for NULL and UNDEF states. It was not the case in one API used by Main UI. When calling transformation and state is NULL or UNDEF, do not apply format to the input value and do not replace by "-". That means the transformation will be called with "NULL" or "UNDEF". Sitemap API was calling the transformation using a pattern containing "-". Fix openhab#4101 Also related to discussion in openhab/openhab-addons#13777 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Proposed changes are now implemented in PR openhab/openhab-core#4203 |
Use item state formatter to format input of transformation, meaning using state.format(format) instead of String.format(format, state.toString()) This was already the case in sitemap API but not in other APIs used by Main UI. Make sure to call transformation even for NULL and UNDEF states. It was not the case in one API used by Main UI. When calling transformation and state is NULL or UNDEF, do not apply format to the input value and do not replace by "-". That means the transformation will be called with "NULL" or "UNDEF". Sitemap API was calling the transformation using a pattern containing "-". Fix openhab#4101 Also related to discussion in openhab/openhab-addons#13777 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
I have a switch in an
.items
file:The file transforms/switch.map contains:
If the
-=-
is missing, there is an exception:In a
.sitemap
file I haveMy understanding is that a Switch can have only three states: ON, OFF and UNDEFINED⇔NULL. When the value was never set, Main UI shows at
http://…:8080/settings/items/
NULL for the UNDEFINED value.Once the value for the switch is set and the device is disconnected, in openhab-JS and I call one of these two options:
the value NULL is searched in transforms/switch.map. But switch.map has no
NULL=
.The point is, if the
.items
file contains no[MAP(switch.map):%s]
, but sitemap hasSwitch item=r2 label="2 Реле [MAP(switch.map):%s]"
, then transform/switch.map does not need to containNULL=
line.The problem report is that after sending
items.getItem("name_it").postUpdate("NULL")
to an item with label"2 Реле [MAP(switch.map):%s]"
, the lookup value in switch.map should be-=
, but it isNULL=
.Currently it is unclear for which state
-=
stands for. It is neither forNULL
, nor forUNDEFINED
.I use openHAB 3.3.
The text was updated successfully, but these errors were encountered: