mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
[dsmr] Fix incorrect deriving of sub channel names when updating channels (#13076)
Subchannels were created by appending the key. However this was done inside a loop and if multiple updates were needed they would be appended to the channel name, instead of taking the channel name each time. Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
This commit is contained in:
parent
3e8df2bff8
commit
a58ae57942
@ -136,15 +136,13 @@ public class DSMRMeterHandler extends BaseThingHandler implements P1TelegramList
|
|||||||
private synchronized void updateState() {
|
private synchronized void updateState() {
|
||||||
logger.trace("Update state for device: {}", getThing().getThingTypeUID().getId());
|
logger.trace("Update state for device: {}", getThing().getThingTypeUID().getId());
|
||||||
if (!lastReceivedValues.isEmpty()) {
|
if (!lastReceivedValues.isEmpty()) {
|
||||||
for (CosemObject cosemObject : lastReceivedValues) {
|
for (final CosemObject cosemObject : lastReceivedValues) {
|
||||||
String channel = cosemObject.getType().name().toLowerCase();
|
for (final Entry<String, ? extends State> entry : cosemObject.getCosemValues().entrySet()) {
|
||||||
|
final String channel = cosemObject.getType().name().toLowerCase()
|
||||||
|
/* CosemObject has a specific sub channel if key not empty */
|
||||||
|
+ (entry.getKey().isEmpty() ? "" : "_" + entry.getKey());
|
||||||
|
|
||||||
for (Entry<String, ? extends State> entry : cosemObject.getCosemValues().entrySet()) {
|
final State newState = entry.getValue();
|
||||||
if (!entry.getKey().isEmpty()) {
|
|
||||||
/* CosemObject has a specific sub channel */
|
|
||||||
channel += "_" + entry.getKey();
|
|
||||||
}
|
|
||||||
State newState = entry.getValue();
|
|
||||||
logger.debug("Updating state for channel {} to value {}", channel, newState);
|
logger.debug("Updating state for channel {} to value {}", channel, newState);
|
||||||
updateState(channel, newState);
|
updateState(channel, newState);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user