Skip to content

Commit

Permalink
[tacmi] initial WIP-Checkin of the "Schema API Page" variant
Browse files Browse the repository at this point in the history
  • Loading branch information
marvkis committed Aug 2, 2020
1 parent 39262b4 commit 20d8d39
Show file tree
Hide file tree
Showing 12 changed files with 1,355 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.tacmi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Sample _.sitemap_ snipplet
sitemap heatingTA label="heatingTA"
{
Text item=TACMI_Analog_In_1
Setpoint item=TACMI_Analog_Out_1 step=5 minValue=15 maxValue=45
Setpoint item=TACMI_Analog_Out_1 step=5 minValue=15 maxValue=45
Switch item=TACMI_Digital_In_1
Switch item=TACMI_Digital_Out_1
}
Expand Down
10 changes: 9 additions & 1 deletion bundles/org.openhab.binding.tacmi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>2.5.6-SNAPSHOT</version>
<version>2.5.8-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.tacmi</artifactId>

<name>openHAB Add-ons :: Bundles :: TA C.M.I. Binding</name>

<dependencies>
<dependency>
<groupId>org.attoparser</groupId>
<artifactId>attoparser</artifactId>
<version>2.0.5.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class TACmiBindingConstants {
// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_CMI = new ThingTypeUID(BINDING_ID, "cmi");
public static final ThingTypeUID THING_TYPE_COE_BRIDGE = new ThingTypeUID(BINDING_ID, "coe-bridge");
public static final ThingTypeUID THING_TYPE_CMI_SCHEMA = new ThingTypeUID(BINDING_ID, "cmiSchema");

public static final ChannelTypeUID CHANNEL_TYPE_COE_DIGITAL_IN_UID = new ChannelTypeUID(BINDING_ID,
"coe-digital-in");
Expand All @@ -40,6 +41,15 @@ public class TACmiBindingConstants {
public static final ChannelTypeUID CHANNEL_TYPE_COE_ANALOG_OUT_UID = new ChannelTypeUID(BINDING_ID,
"coe-analog-out");

public static final ChannelTypeUID CHANNEL_TYPE_SCHEME_SWITCH_RO_UID = new ChannelTypeUID(BINDING_ID,
"schema-switch-ro");
public static final ChannelTypeUID CHANNEL_TYPE_SCHEME_SWITCH_RW_UID = new ChannelTypeUID(BINDING_ID,
"schema-switch-rw");
public static final ChannelTypeUID CHANNEL_TYPE_SCHEME_NUMERIC_RO_UID = new ChannelTypeUID(BINDING_ID,
"schema-numeric-ro");
public static final ChannelTypeUID CHANNEL_TYPE_SCHEME_STATE_RO_UID = new ChannelTypeUID(BINDING_ID,
"schema-state-ro");

// Channel specific configuration items
public final static String CHANNEL_CONFIG_OUTPUT = "output";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.tacmi.internal;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.thing.type.ChannelType;
import org.eclipse.smarthome.core.thing.type.ChannelTypeProvider;
import org.eclipse.smarthome.core.thing.type.ChannelTypeUID;
import org.osgi.service.component.annotations.Component;

/**
* Provides all ChannelTypes for the schema binding...
*
* @author Christian Niessner (marvkis) - Initial contribution
*/
@NonNullByDefault
@Component(service = { TACmiChannelTypeProvider.class, ChannelTypeProvider.class }, immediate = true)
public class TACmiChannelTypeProvider implements ChannelTypeProvider {

private final Map<ChannelTypeUID, ChannelType> channelTypesByUID = new HashMap<>();

@Override
public Collection<ChannelType> getChannelTypes(@Nullable Locale locale) {
return Collections.unmodifiableCollection(channelTypesByUID.values());
}

@Override
public @Nullable ChannelType getChannelType(ChannelTypeUID channelTypeUID, @Nullable Locale locale) {
return channelTypesByUID.get(channelTypeUID);
}

public ChannelType getInternalChannelType(ChannelTypeUID channelTypeUID) {
return channelTypesByUID.get(channelTypeUID);
}

public void addChannelType(ChannelType channelType) {
channelTypesByUID.put(channelType.getUID(), channelType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.smarthome.core.thing.Bridge;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.eclipse.smarthome.io.net.http.HttpClientFactory;
import org.openhab.binding.tacmi.internal.schema.TACmiSchemaHandler;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link TACmiHandlerFactory} is responsible for creating things and thing
Expand All @@ -39,8 +44,18 @@
@Component(configurationPid = "binding.tacmi", service = ThingHandlerFactory.class)
public class TACmiHandlerFactory extends BaseThingHandlerFactory {

private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
.unmodifiableSet(Stream.of(THING_TYPE_CMI, THING_TYPE_COE_BRIDGE).collect(Collectors.toSet()));
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(
Stream.of(THING_TYPE_CMI, THING_TYPE_COE_BRIDGE, THING_TYPE_CMI_SCHEMA).collect(Collectors.toSet()));

private HttpClient httpClient;
private TACmiChannelTypeProvider channelTypeProvider;

@Activate
public TACmiHandlerFactory(@Reference HttpClientFactory httpClientFactory,
@Reference TACmiChannelTypeProvider channelTypeProvider) {
this.httpClient = httpClientFactory.getCommonHttpClient();
this.channelTypeProvider = channelTypeProvider;
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
Expand All @@ -55,8 +70,11 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return new TACmiHandler(thing);
} else if (THING_TYPE_COE_BRIDGE.equals(thingTypeUID)) {
return new TACmiCoEBridgeHandler((Bridge) thing);
} else if (THING_TYPE_CMI_SCHEMA.equals(thingTypeUID)) {
return new TACmiSchemaHandler(thing, httpClient, channelTypeProvider);
}

return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.tacmi.internal.schema;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.thing.Channel;

/**
* The {@link ApiPageEntry} class contains mapping information for an entry of
* the API page.
*
* @author Christian Niessner (marvkis) - Initial contribution
*/
@NonNullByDefault
public class ApiPageEntry {

static enum Type {
ReadOnlySwitch(true), ReadOnlyNumeric(true), NumericForm(false), SwitchButton(false), SwitchForm(false), ReadOnlyState(true), StateForm(false);

public final boolean readOnly;

private Type(boolean readOnly) {
this.readOnly = readOnly;
}
}

/**
* type of this entry
*/
public final Type type;

/**
* The channel for this entry
*/
public final Channel channel;

/**
* internal address for this channel
*/
public final @Nullable String address;

/**
* data for handle 'changerx2' form fields
*/
public final @Nullable ChangerX2Entry changerX2Entry;

protected ApiPageEntry(final Type type, final Channel channel, @Nullable final String address, @Nullable ChangerX2Entry changerX2Entry) {
this.type = type;
this.channel = channel;
this.address = address;
this.changerX2Entry = changerX2Entry;
}
}
Loading

0 comments on commit 20d8d39

Please sign in to comment.