Skip to content
Snippets Groups Projects
Commit fd9c1605 authored by Manuel Krombholz's avatar Manuel Krombholz
Browse files

Added default mqtt port and fixed resolving bug

parent 8921b496
No related branches found
No related tags found
No related merge requests found
Pipeline #10485 passed
......@@ -3,16 +3,16 @@ aspect LastChanged {
this.setValue(Instant.now());
}
public boolean LastChanged.checkStateProcessingTime(FrequencySetting FrequencySetting) {
if (FrequencySetting == null) {
public boolean LastChanged.checkStateProcessingTime(FrequencySetting frequencySetting) {
if (frequencySetting == null) {
return true;
}
double frequency = FrequencySetting.getEventProcessingFrequency();
double frequency = frequencySetting.getEventProcessingFrequency();
Instant lastStateChange = this.getValue();
if (lastStateChange == null) {
return true;
}
return lastStateChange.toEpochMilli() + (1 / frequency) * 1000 < Instant.now().toEpochMilli();
return Instant.now().toEpochMilli() - lastStateChange.toEpochMilli() > (1 / frequency) * 1000;
}
}
......@@ -118,7 +118,7 @@ aspect Resolving {
syn java.util.Optional<FrequencySetting> SmartHomeEntityModel.resolveFrequencySetting(String performanceId) {
for (FrequencySetting performance : getFrequencySettingList()) {
if (performance.getLabel().equals(performanceId)) {
if (performance.getID().equals(performanceId)) {
return java.util.Optional.of(performance);
}
}
......
......@@ -30,8 +30,9 @@ public class MQTTSenderImpl implements MQTTSender {
@Override
public MQTTSender setHost(ExternalHost host) {
int port = host.getPort()!=0 ? host.getPort() : 1883;
/* The host running the MQTT broker. */
URI hostUri = URI.create("tcp://" + host.getHostName() + ":" + host.getPort());
URI hostUri = URI.create("tcp://" + host.getHostName() + ":" + port);
logger.debug("Host is {}", hostUri);
MQTT mqtt = new MQTT();
String username = host.getUserName();
......
......@@ -53,7 +53,10 @@ public class MqttReceiver implements AutoCloseable {
* Sets the host to receive messages from
*/
public void setHost(ExternalHost externalHost) {
this.host = URI.create("tcp://" + externalHost.getHostName() + ":" + externalHost.getPort());
int port = externalHost.getPort()!=0 ? externalHost.getPort() : 1883;
this.host = URI.create("tcp://" + externalHost.getHostName() + ":" + port);
this.username = externalHost.getUserName();
this.password = externalHost.getPassword();
logger.debug("Host is {}", externalHost.getHostName());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment