Skip to content

Commit

Permalink
init lightnessControlledLightService after all devices are discovered
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreKoepke committed Jan 1, 2024
1 parent 2561ca1 commit 2743ba9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class AutomationService {
private final PowerMeterService powerMeterService;
private final MotionSensorService motionSensorService;
private final RollerShutterService rollerShutterService;
private final LightnessControlledDeviceService lightnessControlledDeviceService;
private final EventBus eventPublisher;

@SuppressWarnings("rawtypes")
Expand All @@ -59,6 +60,7 @@ public void discoverNewDevices() {
powerMeterService.init();
motionSensorService.init();
rollerShutterService.init();
lightnessControlledDeviceService.init();
}

private boolean unknownDevice(Device<?> device) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@
import ch.akop.weathercloud.Weather;
import ch.akop.weathercloud.light.Light;
import io.quarkus.narayana.jta.QuarkusTransaction;
import io.quarkus.runtime.StartupEvent;
import io.vertx.core.Vertx;
import io.vertx.rxjava3.RxHelper;
import java.util.function.Consumer;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
@ApplicationScoped
public class LightnessControlledDeviceService {

private final LightnessControlledDeviceRepository configRepository;
Expand All @@ -28,7 +24,7 @@ public class LightnessControlledDeviceService {
private final Vertx vertx;

@Transactional
void setupWeatherListener(@Observes StartupEvent startup) {
public void init() {
var rxScheduler = RxHelper.blockingScheduler(vertx);
weatherService.getWeather()
.map(Weather::getLight)
Expand Down

0 comments on commit 2743ba9

Please sign in to comment.