Skip to content

Commit

Permalink
Renamed classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tisoft committed Dec 3, 2023
1 parent 6799cfd commit a57d910
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link GrundfosAlphaReaderBindingConstants} class defines common constants, which are
* The {@link GrundfosAlphaBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Markus Heberling - Initial contribution
*/
@NonNullByDefault
public class GrundfosAlphaReaderBindingConstants {
public class GrundfosAlphaBindingConstants {

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_MI401 = new ThingTypeUID(BluetoothBindingConstants.BINDING_ID, "mi401");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
*/
@NonNullByDefault
@Component
public class GrundfosAlphaReaderDiscoveryParticipant implements BluetoothDiscoveryParticipant {
private final Logger logger = LoggerFactory.getLogger(GrundfosAlphaReaderDiscoveryParticipant.class);
public class GrundfosAlphaDiscoveryParticipant implements BluetoothDiscoveryParticipant {
private final Logger logger = LoggerFactory.getLogger(GrundfosAlphaDiscoveryParticipant.class);

@Override
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
return Collections.singleton(GrundfosAlphaReaderBindingConstants.THING_TYPE_MI401);
return Collections.singleton(GrundfosAlphaBindingConstants.THING_TYPE_MI401);
}

@Override
Expand All @@ -60,7 +60,7 @@ public boolean requiresConnection(BluetoothDiscoveryDevice device) {
logger.debug("Discovered device {} with manufacturerId {} and name {}", device.getAddress(), manufacturerId,
name);
if ("MI401".equals(name)) {
return new ThingUID(GrundfosAlphaReaderBindingConstants.THING_TYPE_MI401, device.getAdapter().getUID(),
return new ThingUID(GrundfosAlphaBindingConstants.THING_TYPE_MI401, device.getAdapter().getUID(),
device.getAddress().toString().toLowerCase().replace(":", ""));
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
package org.openhab.binding.bluetooth.grundfosalpha.internal;

import static org.openhab.binding.bluetooth.grundfosalpha.internal.GrundfosAlphaReaderBindingConstants.*;
import static org.openhab.binding.bluetooth.grundfosalpha.internal.GrundfosAlphaBindingConstants.*;

import javax.measure.quantity.Dimensionless;
import javax.measure.quantity.Length;
Expand All @@ -31,17 +31,17 @@
import org.slf4j.LoggerFactory;

/**
* The {@link GrundfosAlphaReaderHandler} is responsible for handling commands, which are
* The {@link GrundfosAlphaHandler} is responsible for handling commands, which are
* sent to one of the channels.
*
* @author Markus Heberling - Initial contribution
*/
@NonNullByDefault
public class GrundfosAlphaReaderHandler extends BeaconBluetoothHandler implements BluetoothDeviceListener {
public class GrundfosAlphaHandler extends BeaconBluetoothHandler implements BluetoothDeviceListener {

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

public GrundfosAlphaReaderHandler(Thing thing) {
public GrundfosAlphaHandler(Thing thing) {
super(thing);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
package org.openhab.binding.bluetooth.grundfosalpha.internal;

import static org.openhab.binding.bluetooth.grundfosalpha.internal.GrundfosAlphaReaderBindingConstants.*;
import static org.openhab.binding.bluetooth.grundfosalpha.internal.GrundfosAlphaBindingConstants.*;

import java.util.Set;

Expand All @@ -26,14 +26,14 @@
import org.osgi.service.component.annotations.Component;

/**
* The {@link GrundfosAlphaReaderHandlerFactory} is responsible for creating things and thing
* The {@link GrundfosAlphaHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Markus Heberling - Initial contribution
*/
@NonNullByDefault
@Component(configurationPid = "binding.bluetooth.grundfosalpha", service = ThingHandlerFactory.class)
public class GrundfosAlphaReaderHandlerFactory extends BaseThingHandlerFactory {
public class GrundfosAlphaHandlerFactory extends BaseThingHandlerFactory {

private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_MI401);

Expand All @@ -47,7 +47,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (THING_TYPE_MI401.equals(thingTypeUID)) {
return new GrundfosAlphaReaderHandler(thing);
return new GrundfosAlphaHandler(thing);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# add-on

addon.grundfosalpha.name = GrundfosAlpha Binding
addon.grundfosalpha.description = This is the binding for GrundfosAlpha.
addon.grundfosalpha.description = This is the binding for Grundfos Alpha circulator pumps.

# thing types

Expand All @@ -18,6 +18,6 @@ thing-type.config.bluetooth.mi401.address.description = Bluetooth address in XX:
channel-type.grundfosalpha.grundfos-flow.label = Current Flow
channel-type.grundfosalpha.grundfos-flow.description = Current flow
channel-type.grundfosalpha.grundfos-head.label = Current Head
channel-type.grundfosalpha.grundfos-head.description = Current Head
channel-type.grundfosalpha.grundfos-head.description = Current head
channel-type.grundfosalpha.grundfos-temperature.label = Current Pump Temperature
channel-type.grundfosalpha.grundfos-temperature.description = Current pump temperature
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
import org.openhab.core.util.HexUtils;

/**
* Test the {@link GrundfosAlphaReaderHandler}.
* Test the {@link GrundfosAlphaHandler}.
*
* @author Markus Heberling - Initial contribution
*/
@ExtendWith(MockitoExtension.class)
class GrundfosAlphaReaderHandlerTest {
class GrundfosAlphaHandlerTest {

private @Mock Thing thingMock;

Expand All @@ -50,7 +50,7 @@ public void testMessageType0xf1() {
byte[] data = HexUtils.hexToBytes("15f130017a5113030300994109589916613003004005");
final BluetoothScanNotification scanNotification = new BluetoothScanNotification();
scanNotification.setManufacturerData(data);
final GrundfosAlphaReaderHandler handler = new GrundfosAlphaReaderHandler(thingMock);
final GrundfosAlphaHandler handler = new GrundfosAlphaHandler(thingMock);
handler.setCallback(callback);
handler.onScanRecordReceived(scanNotification);

Expand All @@ -62,29 +62,28 @@ public void testMessageType0xf1() {

@Test
public void testMessageType0xf2() {
when(thingMock.getUID())
.thenReturn(new ThingUID(GrundfosAlphaReaderBindingConstants.THING_TYPE_MI401, "dummy"));
when(thingMock.getUID()).thenReturn(new ThingUID(GrundfosAlphaBindingConstants.THING_TYPE_MI401, "dummy"));

byte[] data = HexUtils.hexToBytes("14f23001650305065419b9180f011f007c1878170d");
final BluetoothScanNotification scanNotification = new BluetoothScanNotification();
scanNotification.setManufacturerData(data);
final GrundfosAlphaReaderHandler handler = new GrundfosAlphaReaderHandler(thingMock);
final GrundfosAlphaHandler handler = new GrundfosAlphaHandler(thingMock);
handler.setCallback(callback);
handler.onScanRecordReceived(scanNotification);

verify(callback).statusUpdated(thingMock,
new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null));
verify(callback).stateUpdated(
new ChannelUID(thingMock.getUID(), GrundfosAlphaReaderBindingConstants.CHANNEL_TYPE_BATTERY_LEVEL),
new ChannelUID(thingMock.getUID(), GrundfosAlphaBindingConstants.CHANNEL_TYPE_BATTERY_LEVEL),
new QuantityType<>(75, Units.PERCENT));
verify(callback).stateUpdated(
new ChannelUID(thingMock.getUID(), GrundfosAlphaReaderBindingConstants.CHANNEL_TYPE_FLOW_RATE),
new ChannelUID(thingMock.getUID(), GrundfosAlphaBindingConstants.CHANNEL_TYPE_FLOW_RATE),
new QuantityType<>(0.98939496, Units.CUBICMETRE_PER_HOUR));
verify(callback).stateUpdated(
new ChannelUID(thingMock.getUID(), GrundfosAlphaReaderBindingConstants.CHANNEL_TYPE_PUMP_HEAD),
new ChannelUID(thingMock.getUID(), GrundfosAlphaBindingConstants.CHANNEL_TYPE_PUMP_HEAD),
new QuantityType<>(1.9315165, SIUnits.METRE));
verify(callback).stateUpdated(
new ChannelUID(thingMock.getUID(), GrundfosAlphaReaderBindingConstants.CHANNEL_TYPE_PUMP_TEMPERATUR),
new ChannelUID(thingMock.getUID(), GrundfosAlphaBindingConstants.CHANNEL_TYPE_PUMP_TEMPERATUR),
new QuantityType<>(31, SIUnits.CELSIUS));

verifyNoMoreInteractions(callback);
Expand Down

0 comments on commit a57d910

Please sign in to comment.