43 lines
1.6 KiB
Java
43 lines
1.6 KiB
Java
package de.ph87.home.demo;
|
|
|
|
import de.ph87.home.device.DeviceService;
|
|
import de.ph87.home.knx.property.KnxPropertyService;
|
|
import de.ph87.home.knx.property.KnxPropertyType;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
|
import org.springframework.context.event.EventListener;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import tuwien.auto.calimero.GroupAddress;
|
|
|
|
@Slf4j
|
|
@Service
|
|
@Transactional
|
|
@RequiredArgsConstructor
|
|
public class DemoService {
|
|
|
|
private final KnxPropertyService knxPropertyService;
|
|
|
|
private final DeviceService deviceService;
|
|
|
|
@EventListener(ApplicationStartedEvent.class)
|
|
public void startup() {
|
|
knxPropertyService.create("fernseher", KnxPropertyType.BOOLEAN, adr(20), adr(4));
|
|
knxPropertyService.create("verstaerker", KnxPropertyType.BOOLEAN, adr(825), adr(824));
|
|
knxPropertyService.create("receiver", KnxPropertyType.BOOLEAN, adr(2561), adr(2560));
|
|
|
|
deviceService.create("EG Ambiente", "eg_ambiente", "eg_ambiente");
|
|
deviceService.create("Wohnzimmer Fernseher", "fernseher", "fernseher");
|
|
deviceService.create("Wohnzimmer Verstärker", "verstaerker", "verstaerker");
|
|
deviceService.create("Wohnzimmer Fensterdeko", "fensterdeko", "fensterdeko");
|
|
deviceService.create("Wohnzimmer Hängelampe", "haengelampe", "haengelampe");
|
|
deviceService.create("Receiver", "receiver", "receiver");
|
|
}
|
|
|
|
private static GroupAddress adr(final int rawGroupAddress) {
|
|
return GroupAddress.freeStyle(rawGroupAddress);
|
|
}
|
|
|
|
}
|