Skip to content

Commit

Permalink
add new endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreKoepke committed Feb 23, 2025
1 parent d5d900f commit 1dd8476
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

import ch.akop.homesystem.controller.dtos.LightDto;
import ch.akop.homesystem.controller.dtos.SensorDto;
import ch.akop.homesystem.models.devices.actor.RollerShutter;
import ch.akop.homesystem.models.devices.actor.SimpleLight;
import ch.akop.homesystem.models.devices.sensor.MotionSensor;
import ch.akop.homesystem.models.devices.sensor.Sensor;
import ch.akop.homesystem.services.impl.DeviceService;
import java.util.stream.Stream;
import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -52,4 +54,18 @@ public SensorDto getSensor(@PathParam("id") String id) {
.map(SensorDto::from)
.orElseThrow(() -> new NotFoundException(id));
}

@POST
@Path("roller-shutters/open-all")
public void openAllRollerShutters() {
deviceService.getDevicesOfType(RollerShutter.class)
.forEach(rollerShutter -> rollerShutter.open("open-all").subscribe());
}

@POST
@Path("roller-shutters/close-all")
public void closeAllRollerShutters() {
deviceService.getDevicesOfType(RollerShutter.class)
.forEach(rollerShutter -> rollerShutter.open("close-all").subscribe());
}
}

0 comments on commit 1dd8476

Please sign in to comment.