Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to core changes (ThingHandlerService) #16107

Merged
merged 183 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
72b9c6d
airquality
J-N-K Dec 28, 2023
520efbb
alarmdecoder
J-N-K Dec 28, 2023
bae26b9
amplipi
J-N-K Dec 28, 2023
410a25e
astro
J-N-K Dec 28, 2023
5ebd307
asuswrt
J-N-K Dec 28, 2023
e31a76b
automower
J-N-K Dec 28, 2023
4c3aad5
avmfritz
J-N-K Dec 24, 2023
50df5df
bondhome
J-N-K Dec 28, 2023
6241974
boschindego
J-N-K Dec 28, 2023
d866114
boschshc
J-N-K Dec 28, 2023
6235b6c
bticiosmarther
J-N-K Dec 28, 2023
ec67fe5
caddx
J-N-K Dec 28, 2023
519f4cb
chatgpt
J-N-K Dec 29, 2023
6dae3cb
chromecast
J-N-K Dec 29, 2023
b34dbab
dbquery
J-N-K Dec 29, 2023
bd40b98
deconz
J-N-K Dec 24, 2023
b778244
digiplex
J-N-K Dec 29, 2023
e49a2af
dmx
J-N-K Dec 29, 2023
fc3ce79
doorbird
J-N-K Dec 29, 2023
6deae84
draytonwiser
J-N-K Dec 29, 2023
cffb925
dsmr
J-N-K Dec 29, 2023
4ddc7be
easee
J-N-K Dec 29, 2023
9522b07
echonetlite
J-N-K Dec 29, 2023
5514cd1
ecobee
J-N-K Dec 29, 2023
efbd71d
ecovacs
J-N-K Dec 29, 2023
4f987c7
electroluxair
J-N-K Dec 29, 2023
dc97436
elroconnects
J-N-K Dec 29, 2023
377aedb
energiedataservice
J-N-K Dec 29, 2023
9349d2d
enigma2
J-N-K Dec 29, 2023
6fd9933
enphase
J-N-K Dec 29, 2023
3888f63
foobot
J-N-K Dec 29, 2023
9e3faf6
freenbox
J-N-K Dec 29, 2023
9931266
freeboxos
J-N-K Dec 29, 2023
d6ef36d
gardena
J-N-K Dec 29, 2023
5b551c3
gce
J-N-K Dec 29, 2023
fa386f0
groupepsa
J-N-K Dec 29, 2023
3b6da3b
haywardomnilogic
J-N-K Dec 29, 2023
f790ced
heos
J-N-K Dec 29, 2023
cfcafcf
homeconnect
J-N-K Dec 29, 2023
45d4ad3
homematic
J-N-K Dec 29, 2023
148f123
hue
J-N-K Dec 29, 2023
850a985
hydrawise
J-N-K Dec 29, 2023
44acfbb
ipcamera
J-N-K Dec 29, 2023
93e1aaa
jablotron
J-N-K Dec 29, 2023
39da353
jellyfin
J-N-K Dec 29, 2023
fd9a718
juicenet
J-N-K Dec 29, 2023
305cec6
kaleidescape
J-N-K Dec 29, 2023
8064364
lcn
J-N-K Dec 29, 2023
8915ab7
lgwebos
J-N-K Dec 29, 2023
f55ffae
livisismarthome
J-N-K Dec 29, 2023
9842f7d
lutron
J-N-K Dec 29, 2023
1212ddb
mail
J-N-K Dec 29, 2023
d10e077
max
J-N-K Dec 29, 2023
482b337
meater
J-N-K Dec 29, 2023
0843cdd
melcloud
J-N-K Dec 29, 2023
284cd9d
mielecloud
J-N-K Dec 29, 2023
1a8d4d3
modbus
J-N-K Dec 29, 2023
05f3aa8
mpd
J-N-K Dec 29, 2023
c496561
mqtt
J-N-K Dec 29, 2023
0488a66
mybmw
J-N-K Dec 29, 2023
6588556
mynice
J-N-K Dec 29, 2023
9fe49c4
nanoleaf
J-N-K Dec 29, 2023
f9f5711
nest
J-N-K Dec 29, 2023
c01ff80
netatmo
J-N-K Dec 29, 2023
25708f6
network
J-N-K Dec 29, 2023
65432f3
networkupstools
J-N-K Dec 29, 2023
a56046c
nikobus
J-N-K Dec 29, 2023
3c7d578
nikohomecontrol
J-N-K Dec 29, 2023
6871fa9
nobohub
J-N-K Dec 29, 2023
f6d74f7
nuki
J-N-K Dec 29, 2023
04224eb
nuvo
J-N-K Dec 29, 2023
f3fb481
ojelectronics
J-N-K Dec 29, 2023
338c52a
omnilink
J-N-K Dec 29, 2023
f4abade
onewire
J-N-K Dec 29, 2023
2d5cba9
onkyo
J-N-K Dec 29, 2023
f6d39a1
openuv
J-N-K Dec 29, 2023
c6686d7
openwebnet
J-N-K Dec 29, 2023
2be83da
orbitbhyve
J-N-K Dec 29, 2023
bc598e3
pilight
J-N-K Dec 30, 2023
bf7b287
plugwise
J-N-K Dec 30, 2023
6693094
plugwiseha
J-N-K Dec 30, 2023
15e9b70
powermax
J-N-K Dec 30, 2023
efa8c8f
prowl
J-N-K Dec 30, 2023
ed5d45d
pushbullet
J-N-K Dec 30, 2023
a46b18c
pushover
J-N-K Dec 30, 2023
0ce76ce
pushsafer
J-N-K Dec 30, 2023
0e7a198
qolsysiq
J-N-K Dec 30, 2023
8b389b3
radiothermostat
J-N-K Dec 30, 2023
5fda38a
remoteopenhab
J-N-K Dec 30, 2023
26d2678
resol
J-N-K Dec 30, 2023
42481fb
rfxcom
J-N-K Dec 30, 2023
5c20f48
satel
J-N-K Dec 30, 2023
d621d3b
sensibo
J-N-K Dec 30, 2023
956049b
smsmodem
J-N-K Dec 30, 2023
c899d64
sncf
J-N-K Dec 30, 2023
79d1dc4
solarwatt
J-N-K Dec 30, 2023
13466f7
somfymylink
J-N-K Dec 30, 2023
0c6410e
somfytahoma
J-N-K Dec 30, 2023
c6b92ed
souliss
J-N-K Dec 30, 2023
3ac79e0
spotify
J-N-K Dec 30, 2023
241314c
surepetcare
J-N-K Dec 30, 2023
d75e4ff
tapocontrol
J-N-K Dec 30, 2023
f456570
telegram
J-N-K Dec 30, 2023
e564fd6
teleinfo
J-N-K Dec 30, 2023
1887bcf
tesla
J-N-K Dec 30, 2023
983abd7
touchwand
J-N-K Dec 30, 2023
816aa6a
tplinksmarthome
J-N-K Dec 30, 2023
76b64dc
tr064
J-N-K Dec 30, 2023
5e8e00d
tradfri
J-N-K Dec 30, 2023
cde744c
unifi
J-N-K Dec 30, 2023
d1e4812
velbus
J-N-K Dec 30, 2023
f1a792b
velux
J-N-K Dec 30, 2023
1a01207
verisure
J-N-K Dec 30, 2023
b7e4790
vesync
J-N-K Dec 30, 2023
43daf87
volvooncall
J-N-K Dec 30, 2023
82f003d
warmup
J-N-K Dec 30, 2023
304e9c3
webexteams
J-N-K Dec 30, 2023
2e82102
windcentrale
J-N-K Dec 30, 2023
cc25b85
wled
J-N-K Dec 30, 2023
c23b738
wolfsmartset
J-N-K Dec 30, 2023
4b228b2
x
J-N-K Dec 30, 2023
1fc884c
xmltv
J-N-K Dec 30, 2023
cf91935
xmppclient
J-N-K Dec 30, 2023
d229389
yamahareceiver
J-N-K Dec 30, 2023
2941ea1
yioremote
J-N-K Dec 30, 2023
35ee0bd
zoneminder
J-N-K Dec 30, 2023
b3fc802
airquality
J-N-K Dec 30, 2023
ab54a9a
amplipi
J-N-K Dec 30, 2023
d74abb2
asuswrt
J-N-K Dec 30, 2023
8ccb537
avmfritz
J-N-K Dec 30, 2023
ba08909
bondhome
J-N-K Dec 30, 2023
63c1016
boschindego
J-N-K Dec 30, 2023
45cdf0e
boschshc
J-N-K Dec 30, 2023
3680618
bticinosmarther
J-N-K Dec 30, 2023
9b0a34a
caddx
J-N-K Dec 30, 2023
2fcfed7
deconz
J-N-K Dec 30, 2023
4aa824b
digiplex
J-N-K Dec 30, 2023
12a6bdf
draytonwiser
J-N-K Dec 30, 2023
a4c6dc8
easee
J-N-K Dec 30, 2023
27b506b
echonet
J-N-K Dec 30, 2023
7ed7065
ecobee
J-N-K Dec 30, 2023
3df19c2
ecovacs
J-N-K Dec 30, 2023
5a899ff
electroluxair
J-N-K Dec 30, 2023
7f26ecf
elroconnects
J-N-K Dec 30, 2023
a0a1e3c
enphase
J-N-K Dec 30, 2023
29da98b
foobot
J-N-K Dec 30, 2023
1b59b07
freebox
J-N-K Dec 30, 2023
0ea2ce5
freeboxos
J-N-K Dec 30, 2023
130c9be
gardena
J-N-K Dec 30, 2023
f11e1be
groupepsa
J-N-K Dec 30, 2023
9da3151
haywardomnilogic
J-N-K Dec 30, 2023
64bddff
homeconnect
J-N-K Dec 30, 2023
3669cad
homematic
J-N-K Dec 30, 2023
ca7ad30
hue
J-N-K Dec 30, 2023
558c75c
hydrawise
J-N-K Dec 30, 2023
77f5f74
jellyfin
J-N-K Dec 30, 2023
a4abee0
juicenet
J-N-K Dec 30, 2023
654a00f
lcn
J-N-K Dec 30, 2023
49ab5ff
livisismarthome
J-N-K Dec 30, 2023
331a0c0
lutron
J-N-K Dec 30, 2023
a1b0021
max
J-N-K Dec 30, 2023
1369d5a
meater
J-N-K Dec 30, 2023
9f9201a
melcloud
J-N-K Dec 30, 2023
9482fb8
mybmw
J-N-K Dec 30, 2023
5da4f7d
mynice
J-N-K Dec 30, 2023
b0eacc9
mielecloud
J-N-K Dec 30, 2023
140286e
nanoleaf
J-N-K Dec 31, 2023
07676a6
nest
J-N-K Dec 31, 2023
3321fb4
netatmo
J-N-K Dec 31, 2023
0bbd09f
nikobus
J-N-K Dec 31, 2023
dc8b21b
nikohome
J-N-K Dec 31, 2023
bd3091b
nobohub
J-N-K Dec 31, 2023
31face9
ojelectronics
J-N-K Dec 31, 2023
a1754b7
omnilink
J-N-K Dec 31, 2023
6e0c705
onewire
J-N-K Dec 31, 2023
bc0546f
openuv
J-N-K Dec 31, 2023
00e23e6
openwebnet
J-N-K Dec 31, 2023
5a028bd
orbitbhyve
J-N-K Dec 31, 2023
177529b
boschshc
J-N-K Dec 31, 2023
69f12fe
fix
J-N-K Dec 31, 2023
c05f29c
address review comments
J-N-K Jan 2, 2024
9440449
address review comments
J-N-K Jan 2, 2024
bd4a686
address review comments
J-N-K Jan 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {

return THING_TYPE_STATION.equals(thingTypeUID)
? new AirQualityStationHandler(thing, timeZoneProvider, locationProvider)
: BRIDGE_TYPE_API.equals(thingTypeUID) ? new AirQualityBridgeHandler((Bridge) thing, locationProvider)
: null;
: BRIDGE_TYPE_API.equals(thingTypeUID) ? new AirQualityBridgeHandler((Bridge) thing) : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.airquality.internal.handler.AirQualityBridgeHandler;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.AbstractThingHandlerDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.config.discovery.DiscoveryService;
import org.openhab.core.i18n.LocationProvider;
import org.openhab.core.library.types.PointType;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ServiceScope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -38,40 +38,28 @@
*
* @author Gaël L'hopital - Initial Contribution
*/
@Component(service = DiscoveryService.class, configurationPid = "discovery.airquality")
@Component(scope = ServiceScope.PROTOTYPE, service = AirQualityDiscoveryService.class, configurationPid = "discovery.airquality")
@NonNullByDefault
public class AirQualityDiscoveryService extends AbstractDiscoveryService implements ThingHandlerService {
public class AirQualityDiscoveryService extends AbstractThingHandlerDiscoveryService<AirQualityBridgeHandler>
implements ThingHandlerService {
private static final int DISCOVER_TIMEOUT_SECONDS = 2;
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_STATION);

private final Logger logger = LoggerFactory.getLogger(AirQualityDiscoveryService.class);

private @Nullable LocationProvider locationProvider;
private @Nullable AirQualityBridgeHandler bridgeHandler;
private @NonNullByDefault({}) LocationProvider locationProvider;

/**
* Creates an AirQualityDiscoveryService with enabled autostart.
*/
@Activate
public AirQualityDiscoveryService() {
super(SUPPORTED_THING_TYPES_UIDS, DISCOVER_TIMEOUT_SECONDS, false);
super(AirQualityBridgeHandler.class, SUPPORTED_THING_TYPES_UIDS, DISCOVER_TIMEOUT_SECONDS, false);
}

@Override
public void setThingHandler(@Nullable ThingHandler handler) {
if (handler instanceof AirQualityBridgeHandler bridgeHandlerInstance) {
this.bridgeHandler = bridgeHandlerInstance;
this.locationProvider = bridgeHandler.getLocationProvider();
}
}

@Override
public @Nullable ThingHandler getThingHandler() {
return bridgeHandler;
}

@Override
public void deactivate() {
super.deactivate();
@Reference(unbind = "-")
public void bindLocationProvider(LocationProvider locationProvider) {
this.locationProvider = locationProvider;
}

@Override
Expand All @@ -80,7 +68,7 @@ protected void startScan() {
LocationProvider provider = locationProvider;
if (provider != null) {
PointType location = provider.getLocation();
AirQualityBridgeHandler bridge = this.bridgeHandler;
AirQualityBridgeHandler bridge = this.thingHandler;
if (location == null || bridge == null) {
logger.info("openHAB server location is not defined, will not provide any discovery results");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.airquality.internal.api.ApiBridge;
import org.openhab.binding.airquality.internal.discovery.AirQualityDiscoveryService;
import org.openhab.core.i18n.LocationProvider;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.ThingStatus;
Expand All @@ -36,12 +35,10 @@
*/
@NonNullByDefault
public class AirQualityBridgeHandler extends BaseBridgeHandler {
private final LocationProvider locationProvider;
private @Nullable ApiBridge apiBridge;

public AirQualityBridgeHandler(Bridge bridge, LocationProvider locationProvider) {
public AirQualityBridgeHandler(Bridge bridge) {
super(bridge);
this.locationProvider = locationProvider;
}

@Override
Expand Down Expand Up @@ -69,8 +66,4 @@ public void handleCommand(ChannelUID channelUID, Command command) {
public Collection<Class<? extends ThingHandlerService>> getServices() {
return Set.of(AirQualityDiscoveryService.class);
}

public LocationProvider getLocationProvider() {
return locationProvider;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.openhab.core.thing.binding.ThingActions;
import org.openhab.core.thing.binding.ThingActionsScope;
import org.openhab.core.thing.binding.ThingHandler;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ServiceScope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -28,6 +30,7 @@
*
* @author Bob Adair - Initial contribution
*/
@Component(scope = ServiceScope.PROTOTYPE, service = BridgeActions.class)
@ThingActionsScope(name = "alarmdecoder")
@NonNullByDefault
public class BridgeActions implements ThingActions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
import org.openhab.core.thing.type.ChannelTypeUID;
import org.openhab.core.thing.type.DynamicStateDescriptionProvider;
import org.openhab.core.types.StateDescription;
import org.openhab.core.types.StateOption;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ServiceScope;

/**
* This class provides the list of valid inputs for the input channel of a source.
*
* @author Kai Kreuzer - Initial contribution
*
*/
@Component(scope = ServiceScope.PROTOTYPE, service = { DynamicStateDescriptionProvider.class,
InputStateOptionProvider.class })
@NonNullByDefault
public class InputStateOptionProvider extends BaseDynamicStateDescriptionProvider implements ThingHandlerService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
import org.openhab.core.thing.type.ChannelTypeUID;
import org.openhab.core.thing.type.DynamicCommandDescriptionProvider;
import org.openhab.core.types.CommandDescription;
import org.openhab.core.types.CommandOption;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ServiceScope;

/**
* This class provides the list of valid commands for the preset channel.
*
* @author Kai Kreuzer - Initial contribution
*
*/
@Component(scope = ServiceScope.PROTOTYPE, service = { PresetCommandOptionProvider.class,
DynamicCommandDescriptionProvider.class })
@NonNullByDefault
public class PresetCommandOptionProvider extends BaseDynamicCommandDescriptionProvider implements ThingHandlerService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.openhab.core.library.types.PercentType;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ServiceScope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -39,6 +41,7 @@
* @author Kai Kreuzer - Initial contribution
*
*/
@Component(scope = ServiceScope.PROTOTYPE, service = PAAudioSink.class)
@NonNullByDefault
public class PAAudioSink extends AudioSinkSync implements ThingHandlerService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,45 @@
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.amplipi.internal.AmpliPiBindingConstants;
import org.openhab.binding.amplipi.internal.AmpliPiHandler;
import org.openhab.binding.amplipi.internal.AmpliPiStatusChangeListener;
import org.openhab.binding.amplipi.internal.model.Group;
import org.openhab.binding.amplipi.internal.model.Status;
import org.openhab.binding.amplipi.internal.model.Zone;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.AbstractThingHandlerDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ServiceScope;

/**
* This class discoveres the available zones and groups of the AmpliPi system.
*
* @author Kai Kreuzer - Initial contribution
*
*/
@Component(scope = ServiceScope.PROTOTYPE, service = AmpliPiZoneAndGroupDiscoveryService.class)
@NonNullByDefault
public class AmpliPiZoneAndGroupDiscoveryService extends AbstractDiscoveryService
implements ThingHandlerService, AmpliPiStatusChangeListener {
public class AmpliPiZoneAndGroupDiscoveryService extends AbstractThingHandlerDiscoveryService<AmpliPiHandler>
implements AmpliPiStatusChangeListener {

private static final int TIMEOUT = 10;

private @Nullable AmpliPiHandler handler;
private List<Zone> zones = List.of();
private List<Group> groups = List.of();

public AmpliPiZoneAndGroupDiscoveryService() throws IllegalArgumentException {
super(Set.of(AmpliPiBindingConstants.THING_TYPE_GROUP, AmpliPiBindingConstants.THING_TYPE_ZONE), TIMEOUT, true);
super(AmpliPiHandler.class,
Set.of(AmpliPiBindingConstants.THING_TYPE_GROUP, AmpliPiBindingConstants.THING_TYPE_ZONE), TIMEOUT,
true);
}

@Override
public void setThingHandler(ThingHandler handler) {
AmpliPiHandler ampliPiHander = (AmpliPiHandler) handler;
ampliPiHander.addStatusChangeListener(this);
this.handler = ampliPiHander;
}

@Override
public @Nullable ThingHandler getThingHandler() {
return handler;
public void initialize() {
thingHandler.addStatusChangeListener(this);
super.initialize();
}

@Override
Expand All @@ -75,33 +70,27 @@ protected void startScan() {
}

private void createZone(Zone z) {
if (handler != null) {
ThingUID bridgeUID = handler.getThing().getUID();
ThingUID uid = new ThingUID(AmpliPiBindingConstants.THING_TYPE_ZONE, bridgeUID, z.getId().toString());
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withLabel("AmpliPi Zone '" + z.getName() + "'")
.withProperty(AmpliPiBindingConstants.CFG_PARAM_ID, z.getId()).withBridge(bridgeUID)
.withRepresentationProperty(AmpliPiBindingConstants.CFG_PARAM_ID).build();
thingDiscovered(result);
}
ThingUID bridgeUID = thingHandler.getThing().getUID();
ThingUID uid = new ThingUID(AmpliPiBindingConstants.THING_TYPE_ZONE, bridgeUID, z.getId().toString());
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withLabel("AmpliPi Zone '" + z.getName() + "'")
.withProperty(AmpliPiBindingConstants.CFG_PARAM_ID, z.getId()).withBridge(bridgeUID)
.withRepresentationProperty(AmpliPiBindingConstants.CFG_PARAM_ID).build();
thingDiscovered(result);
}

private void createGroup(Group g) {
if (handler != null) {
ThingUID bridgeUID = handler.getThing().getUID();
ThingUID uid = new ThingUID(AmpliPiBindingConstants.THING_TYPE_GROUP, bridgeUID, g.getId().toString());
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withLabel("AmpliPi Group '" + g.getName() + "'")
.withProperty(AmpliPiBindingConstants.CFG_PARAM_ID, g.getId()).withBridge(bridgeUID)
.withRepresentationProperty(AmpliPiBindingConstants.CFG_PARAM_ID).build();
thingDiscovered(result);
}
ThingUID bridgeUID = thingHandler.getThing().getUID();
ThingUID uid = new ThingUID(AmpliPiBindingConstants.THING_TYPE_GROUP, bridgeUID, g.getId().toString());
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withLabel("AmpliPi Group '" + g.getName() + "'")
.withProperty(AmpliPiBindingConstants.CFG_PARAM_ID, g.getId()).withBridge(bridgeUID)
.withRepresentationProperty(AmpliPiBindingConstants.CFG_PARAM_ID).build();
thingDiscovered(result);
}

@Override
public void deactivate() {
if (handler != null) {
handler.removeStatusChangeListener(this);
}
super.deactivate();
public void dispose() {
super.dispose();
thingHandler.removeStatusChangeListener(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.openhab.core.thing.binding.ThingActions;
import org.openhab.core.thing.binding.ThingActionsScope;
import org.openhab.core.thing.binding.ThingHandler;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ServiceScope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -39,6 +41,7 @@
*
* @author Gaël L'hopital - Initial contribution
*/
@Component(scope = ServiceScope.PROTOTYPE, service = AstroActions.class)
@ThingActionsScope(name = "astro")
@NonNullByDefault
public class AstroActions implements ThingActions {
Expand Down