Skip to content

Commit 240fc17

Browse files
committed
synchronize config
Signed-off-by: Markus Michels <markus7017@gmail.com>
1 parent 918448e commit 240fc17

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api1

bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api1/Shelly1HttpApi.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ public void muteSmokeAlarm(int id) throws ShellyApiException {
570570
private void setSensorEventUrls() throws ShellyApiException, ShellyApiException {
571571
if (profile.isSensor) {
572572
logger.debug("{}: Set Sensor Reporting URL", thingName);
573+
ShellyThingConfiguration config;
574+
synchronized (this) {
575+
config = this.config;
576+
}
573577
setEventUrl(config.eventsSensorReport, SHELLY_EVENT_SENSORREPORT, SHELLY_EVENT_DARK, SHELLY_EVENT_TWILIGHT,
574578
SHELLY_EVENT_FLOOD_DETECTED, SHELLY_EVENT_FLOOD_GONE, SHELLY_EVENT_OPEN, SHELLY_EVENT_CLOSE,
575579
SHELLY_EVENT_VIBRATION, SHELLY_EVENT_ALARM_MILD, SHELLY_EVENT_ALARM_HEAVY, SHELLY_EVENT_ALARM_OFF,
@@ -584,6 +588,10 @@ private void setSensorEventUrls() throws ShellyApiException, ShellyApiException
584588
* @throws ShellyApiException
585589
*/
586590
private void setEventUrls(Integer index) throws ShellyApiException {
591+
ShellyThingConfiguration config;
592+
synchronized (this) {
593+
config = this.config;
594+
}
587595
if (profile.isRoller) {
588596
setEventUrl(EVENT_TYPE_ROLLER, 0, config.eventsRoller, SHELLY_EVENT_ROLLER_OPEN, SHELLY_EVENT_ROLLER_CLOSE,
589597
SHELLY_EVENT_ROLLER_STOP);
@@ -608,6 +616,11 @@ private void setEventUrls(Integer index) throws ShellyApiException {
608616
}
609617

610618
private void setEventUrl(boolean enabled, String... eventTypes) throws ShellyApiException {
619+
ShellyThingConfiguration config;
620+
synchronized (this) {
621+
config = this.config;
622+
}
623+
611624
if (config.localIp.isEmpty()) {
612625
throw new ShellyApiException(thingName + ": Local IP address was not detected, can't build Callback URL");
613626
}
@@ -636,6 +649,11 @@ private void setEventUrl(boolean enabled, String... eventTypes) throws ShellyApi
636649

637650
private void setEventUrl(String deviceClass, Integer index, boolean enabled, String... eventTypes)
638651
throws ShellyApiException {
652+
ShellyThingConfiguration config;
653+
synchronized (this) {
654+
config = this.config;
655+
}
656+
639657
for (String eventType : eventTypes) {
640658
if (profile.containsEventUrl(eventType)) {
641659
String callBackUrl = "http://" + config.localIp + ":" + config.localPort + SHELLY1_CALLBACK_URI + "/"

0 commit comments

Comments
 (0)