From 5aa1d21ed4252a5ff81d178c668a60f3143bc13a Mon Sep 17 00:00:00 2001 From: russdan Date: Sun, 16 May 2021 15:03:21 +0100 Subject: [PATCH] Fix controlling heat endpoint with occupied_heating_setpoint_heat not working (#7481) * Update publish.js Fix for issue #7470 . Tests: error 2021-05-14 11:37:13: key: occupied_heating_setpoint_heat error 2021-05-14 11:37:13: endpointNameMatch 'heat' (heat) error 2021-05-14 11:37:13: Before replace 'occupied_heating_setpoint_heat' (occupied_heating_setpoint_heat) error 2021-05-14 11:37:13: After replace 'occupied_heating_setpoint' (occupied_heating_setpoint) error 2021-05-14 11:37:26: key: occupied_heating_setpoint_water error 2021-05-14 11:37:26: endpointNameMatch 'water' (water) error 2021-05-14 11:37:26: Before replace 'occupied_heating_setpoint_water' (occupied_heating_setpoint_water) error 2021-05-14 11:37:26: After replace 'occupied_heating_setpoint' (occupied_heating_setpoint) * Update publish.js * Update publish.js Co-authored-by: Koen Kanters --- lib/extension/publish.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/extension/publish.js b/lib/extension/publish.js index 380f50500..254bc405d 100644 --- a/lib/extension/publish.js +++ b/lib/extension/publish.js @@ -170,7 +170,8 @@ class EntityPublish extends Extension { const endpointNameMatch = utils.getEndpointNames().find((n) => key.endsWith(`_${n}`)); if (endpointNameMatch) { endpointName = endpointNameMatch; - key = key.replace(`_${endpointNameMatch}`, ''); + const regex = new RegExp(`(_${endpointNameMatch})$`, 'gm'); + key = key.replace(regex, ``); const device = target.getDevice(); actualTarget = device.getEndpoint(definition.endpoint(device)[endpointName]);