mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
fixup! fixup! [intellicenter2] feat: adds IntelliCenter2 binding for Pentair
This commit is contained in:
parent
419b476cbe
commit
c66de7c65f
@ -17,12 +17,17 @@ import java.net.UnknownHostException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.measure.Unit;
|
||||
import javax.measure.quantity.Temperature;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.intellicenter2.internal.IntelliCenter2Configuration;
|
||||
import org.openhab.binding.intellicenter2.internal.discovery.IntelliCenter2DiscoveryService;
|
||||
import org.openhab.binding.intellicenter2.internal.model.SystemInfo;
|
||||
import org.openhab.binding.intellicenter2.internal.protocol.ICProtocol;
|
||||
import org.openhab.core.library.unit.ImperialUnits;
|
||||
import org.openhab.core.library.unit.SIUnits;
|
||||
import org.openhab.core.thing.Bridge;
|
||||
import org.openhab.core.thing.ChannelUID;
|
||||
import org.openhab.core.thing.Thing;
|
||||
@ -113,6 +118,13 @@ public class IntelliCenter2BridgeHandler extends BaseBridgeHandler {
|
||||
return Futures.getUnchecked(protocolFuture);
|
||||
}
|
||||
|
||||
public Unit<Temperature> getTemperatureUnits() {
|
||||
if (systemInfo != null) {
|
||||
return systemInfo.isMetricSystem() ? SIUnits.CELSIUS : ImperialUnits.FAHRENHEIT;
|
||||
}
|
||||
throw new IllegalStateException("systemInfo was not set yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
scheduler.execute(() -> {
|
||||
|
@ -27,8 +27,8 @@ import org.openhab.binding.intellicenter2.internal.protocol.ICProtocol;
|
||||
import org.openhab.binding.intellicenter2.internal.protocol.ICRequest;
|
||||
import org.openhab.binding.intellicenter2.internal.protocol.ICResponse;
|
||||
import org.openhab.binding.intellicenter2.internal.protocol.ResponseObject;
|
||||
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.thing.ChannelUID;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.slf4j.Logger;
|
||||
@ -52,9 +52,15 @@ public class IntelliCenter2PoolHandler extends IntelliCenter2ThingHandler<Body>
|
||||
|
||||
@Override
|
||||
protected void updateState(Body pool) {
|
||||
final IntelliCenter2BridgeHandler bh = getBridgeHandler();
|
||||
if (bh == null) {
|
||||
return;
|
||||
}
|
||||
updateState(CHANNEL_HEATER_STATUS, OnOffType.from(pool.isHeating()));
|
||||
updateState(CHANNEL_CURRENT_TEMPERATURE, new DecimalType(pool.getCurrentTemperature()));
|
||||
updateState(CHANNEL_TARGET_TEMPERATURE, new DecimalType(pool.getTargetTemperature()));
|
||||
updateState(CHANNEL_CURRENT_TEMPERATURE,
|
||||
new QuantityType<>(pool.getCurrentTemperature(), bh.getTemperatureUnits()));
|
||||
updateState(CHANNEL_TARGET_TEMPERATURE,
|
||||
new QuantityType<>(pool.getTargetTemperature(), bh.getTemperatureUnits()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -72,12 +78,16 @@ public class IntelliCenter2PoolHandler extends IntelliCenter2ThingHandler<Body>
|
||||
|
||||
@Override
|
||||
protected void updateState(ChannelUID channelUID, Body pool) {
|
||||
final IntelliCenter2BridgeHandler bh = getBridgeHandler();
|
||||
if (bh == null) {
|
||||
return;
|
||||
}
|
||||
switch (channelUID.getId()) {
|
||||
case CHANNEL_CURRENT_TEMPERATURE:
|
||||
updateState(channelUID, new DecimalType(pool.getCurrentTemperature()));
|
||||
updateState(channelUID, new QuantityType<>(pool.getCurrentTemperature(), bh.getTemperatureUnits()));
|
||||
break;
|
||||
case CHANNEL_TARGET_TEMPERATURE:
|
||||
updateState(channelUID, new DecimalType(pool.getTargetTemperature()));
|
||||
updateState(channelUID, new QuantityType<>(pool.getTargetTemperature(), bh.getTemperatureUnits()));
|
||||
break;
|
||||
case CHANNEL_HEATER_STATUS:
|
||||
updateState(channelUID, OnOffType.from(pool.isHeating()));
|
||||
|
@ -51,6 +51,10 @@ public class SystemInfo extends ResponseModel {
|
||||
return getValueAsString(MODE);
|
||||
}
|
||||
|
||||
public boolean isMetricSystem() {
|
||||
return "METRIC".equals(getMode());
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return getValueAsString(VER);
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
# FIXME: please substitute the xx with a proper locale, ie. de
|
||||
# FIXME: please do not add the file to the repo if you add or change no content
|
||||
# binding
|
||||
binding.intellicenter2.name = <Your localized Binding name>
|
||||
binding.intellicenter2.description = <Your localized Binding description>
|
||||
|
||||
# thing types
|
||||
thing-type.intellicenter2.sample.label = <Your localized Thing label>
|
||||
thing-type.intellicenter2.sample.description = <Your localized Thing description>
|
||||
|
||||
# thing type config description
|
||||
thing-type.config.intellicenter2.sample.hostname.label = <Your localized config parameter label>
|
||||
thing-type.config.intellicenter2.sample.hostname.description = <Your localized config parameter description>
|
||||
thing-type.config.intellicenter2.sample.password.label = <Your localized config parameter label>
|
||||
thing-type.config.intellicenter2.sample.password.description = <Your localized config parameter description>
|
||||
thing-type.config.intellicenter2.sample.refreshInterval.label = <Your localized config parameter label>
|
||||
thing-type.config.intellicenter2.sample.refreshInterval.description = <Your localized config parameter description>
|
||||
|
||||
# channel types
|
||||
channel-type.intellicenter2.sample-channel.label = <Your localized Channel label>
|
||||
channel-type.intellicenter2.sample-channel.description = <Your localized Channel description>
|
@ -127,21 +127,21 @@
|
||||
<item-type>Number:Temperature</item-type>
|
||||
<label>Temperature</label>
|
||||
<description>The temperature value.</description>
|
||||
<state readOnly="true"/>
|
||||
<state readOnly="true" pattern="%.1f %unit%"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="temperature-current">
|
||||
<item-type>Number:Temperature</item-type>
|
||||
<label>Temperature</label>
|
||||
<description>The current temperature value.</description>
|
||||
<state readOnly="true"/>
|
||||
<state readOnly="true" pattern="%.1f %unit%"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="temperature-target">
|
||||
<item-type>Number:Temperature</item-type>
|
||||
<label>Temperature</label>
|
||||
<description>The target temperature value.</description>
|
||||
<state readOnly="true"/>
|
||||
<state readOnly="true" pattern="%.1f %unit%"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="heater-status">
|
||||
|
Loading…
Reference in New Issue
Block a user