Closed holgerfriedrich closed 1 year ago
@J-N-K can you comment how the UoM handling should work? The addon seems to get the data as plain number from the framework - handleCommand
always sees the number, not the unit. Or do I overlook something?
openhab> openhab:send time_h "4 s"
21:49:40.426 [TRACE] [knx.internal.client.AbstractKNXClient] - Received a Group Write telegram from '1.1.161' to '5/3/10' with value '[0]'
21:49:42.471 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'time_h' received command 4 s
21:49:42.472 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'time_h' predicted to become 4 s
21:49:42.491 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'time_h' changed from NULL to 4 s
21:49:42.491 [TRACE] [x.internal.handler.DeviceThingHandler] - Handling command '4' for channel 'knx:device:ip:hsb_test:t_t_h'
21:49:42.492 [TRACE] [nding.knx.internal.channel.KNXChannel] - getCommandSpec checking keys '[ga]' for command '4' (class org.openhab.core.library.types.DecimalType)
21:49:42.494 [TRACE] [nding.knx.internal.channel.KNXChannel] - getCommandSpec key 'ga' has expectedTypeClass '[class org.openhab.core.library.types.QuantityType, class org.openhab.core.library.types.DecimalType]', matching command '4' and dpt '7.007'
21:49:42.495 [TRACE] [knx.internal.client.AbstractKNXClient] - writeToKNX groupAddress '10/0/7', commandSpec 'org.openhab.binding.knx.internal.channel.WriteSpecImpl@199986e'
21:49:42.496 [TRACE] [knx.internal.client.AbstractKNXClient] - sendToKNX mappedValue: '4' groupAddress: '10/0/7'
21:49:42.522 [DEBUG] [knx.internal.client.AbstractKNXClient] - Wrote value '4' to datapoint 'command DP 10/0/7 'knx:ip:ip', DPT 7.007, low priority' (0. attempt).
21:49:42.500 1.0.248->10/0/7 A_Group.write 00 04
When I use "4 h" as command, to framework handles the data correctly, but the addon still gets a plain 4 - same as above.
22:04:15.464 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'time_h' received command 4 h
22:04:15.465 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'time_h' predicted to become 4 h
22:04:15.483 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'time_h' changed from 4 s to 14400 s
22:04:15.484 [TRACE] [x.internal.handler.DeviceThingHandler] - Handling command '4' for channel 'knx:device:ip:hsb_test:t_t_h'
Do I miss something?
Core has more strict type checking. As a result the KNX channel (which reports to be Number
which is a plain number without unit) only receives a DecimalType
(unit stripped).
I'll have look how this can be handled. It probably also affects HTTP and MQTT which use a similar concept.
Looking at #15049 there seems to be an issue sending data with UoM from the openHAB console to a KNX installation.
We have defined in item with DPTs 7.007 (time in hours) with textual config. Here are the snippets from
knx.things
anddefault.items
:Receiving data properly respects UoM and converts data to seconds, which is the representation of time on OH.
Using the OH console to send data, however:
The internal state is properly updated for h and s; the wrong unit "kg" is ignored. The last command without unit uses default for time (s).
But the knx addon sends out the data in all 4 cases (even the one with wrong unit). It used the plain number without any conversion. See the bus log:
Expected Behavior
Data converted according to UoM, data on the bus is in hours.
Current Behavior
Possible Solution
Steps to Reproduce (for Bugs)
see above
Context
UoM
Your Environment
Operating System and version (desktop or mobile, Windows 10, Raspbian Buster, ...):
4.0.0-SNAPSHOT - Build 3487, custom build of KNX addon, based on current main branch