diff --git a/bundles/org.openhab.binding.boschshc/README.md b/bundles/org.openhab.binding.boschshc/README.md index 7e159a06d66..5671cb98e2b 100644 --- a/bundles/org.openhab.binding.boschshc/README.md +++ b/bundles/org.openhab.binding.boschshc/README.md @@ -235,9 +235,11 @@ The smart switching relay is your universal all-rounder for smart switching. | child-protection | Switch | ☑ | Indicates whether the child protection is active. | | power-switch | Switch | ☑ | Switches the relay on or off. Only available if the relay is in power switch mode. | | impulse-switch | Switch | ☑ | Channel to send impulses by means of `ON` events. After the time specified by `impulse-length`, the relay will switch off automatically and the state will be reset to `OFF`. Only available if the relay is in impulse switch mode. | -| impulse-length | Number:Time | ☑ | Channel to configure how long the relay will stay on after receiving an impulse switch event. The time is specified in tenth seconds (deciseconds), e.g. 15 means 1.5 seconds. Only available if the relay is in impulse switch mode. | +| impulse-length | Number:Time | ☑ | Channel to configure how long the relay will stay on after receiving an impulse switch event. If raw numbers (without time unit) are provided, the default unit is tenth seconds (deciseconds), e.g. 15 means 1.5 seconds. If quantities with time units are provided, the quantity will be converted to deciseconds internally, discarding any fraction digits that are more precise than expressible in whole deciseconds (e.g. 1.58 seconds will be converted to 15 ds). Only available if the relay is in impulse switch mode. | | instant-of-last-impulse | DateTime | ☐ | Timestamp indicating when the last impulse was triggered. Only available if the relay is in impulse switch mode. | +If the device mode is changed from power switch to impulse switch mode or vice versa, the corresponding thing has to be deleted and re-added in openHAB. + ### Security Camera 360 Indoor security camera with 360° view and motion detection. diff --git a/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/relay/RelayHandler.java b/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/relay/RelayHandler.java index 8dd4784cd39..2d3ec708817 100644 --- a/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/relay/RelayHandler.java +++ b/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/relay/RelayHandler.java @@ -12,7 +12,6 @@ */ package org.openhab.binding.boschshc.internal.devices.relay; -import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.BINDING_ID; import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_CHILD_PROTECTION; import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_IMPULSE_LENGTH; import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_IMPULSE_SWITCH; @@ -23,8 +22,11 @@ import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConst import java.time.Instant; import java.util.List; import java.util.Objects; +import java.util.Optional; import javax.inject.Provider; +import javax.measure.Unit; +import javax.measure.quantity.Time; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -37,17 +39,19 @@ import org.openhab.binding.boschshc.internal.services.communicationquality.Commu import org.openhab.binding.boschshc.internal.services.communicationquality.dto.CommunicationQualityServiceState; import org.openhab.binding.boschshc.internal.services.impulseswitch.ImpulseSwitchService; import org.openhab.binding.boschshc.internal.services.impulseswitch.dto.ImpulseSwitchServiceState; -import org.openhab.core.library.CoreItemFactory; +import org.openhab.binding.boschshc.internal.services.powerswitch.PowerSwitchService; import org.openhab.core.library.types.DateTimeType; import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.OnOffType; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.unit.MetricPrefix; +import org.openhab.core.library.unit.Units; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; -import org.openhab.core.thing.DefaultSystemChannelTypeProvider; import org.openhab.core.thing.Thing; -import org.openhab.core.thing.binding.builder.ChannelBuilder; +import org.openhab.core.thing.ThingStatus; +import org.openhab.core.thing.ThingStatusDetail; import org.openhab.core.thing.binding.builder.ThingBuilder; -import org.openhab.core.thing.type.ChannelTypeUID; import org.openhab.core.types.Command; import org.openhab.core.types.State; import org.openhab.core.types.UnDefType; @@ -79,6 +83,13 @@ public class RelayHandler extends AbstractPowerSwitchHandler { private final Logger logger = LoggerFactory.getLogger(RelayHandler.class); + protected static final String PROPERTY_MODE = "mode"; + + /** + * Unit for the impulse length, which is specified in deciseconds (tenth seconds) + */ + private static final Unit