Skip to content

Commit

Permalink
initial set of fixes and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelrv committed Nov 21, 2014
1 parent 751b7ec commit 45e8433
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xmlns:binding="http://eclipse.org/smarthome/schemas/binding/v1.0.0"
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/binding/v1.0.0 http://eclipse.org/smarthome/schemas/binding-1.0.0.xsd">

<name>MaxCube Binding</name>
<description>This is the binding for eQ-3 MaxCube heating Thermostat.</description>
<name>Max!Cube Binding</name>
<description>This is the binding for eQ-3 Max! Home Solution controlled via the Max!Cube Lan Gateway.</description>
<author>Marcel Verpaalen</author>

</binding:binding>
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
<parameter name="ipAddress" type="text">
<context>network_address</context>
<label>MAX!Cube LAN gateway IP</label>
<description>The IP address of the MAX!Cube LAN gateway. If none provided, binding will try to discover it.</description>
<description>The IP address of the MAX!Cube LAN gateway</description>
<required>false</required>
</parameter>
<parameter name="port" type="integer">
<context>port</context>
<label>MAX!Cube LAN gateway port</label>
<description>
Port of the LAN gateway. If empty, default port 62910 will be used.
</description>
<description>Port of the LAN gateway</description>
<default>62910</default>
<required>false</required>
</parameter>
<parameter name="refreshInterval" type="integer">
<label>Refresh Interval</label>
<description>The refresh interval in ms which is used to poll given MAX!Cube.</description>
<default>30000</default>
<required>false</required>
</parameter>
<parameter name="serialNumber" type="text">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<description>MaxCube HeathingThermostat</description>

<channels>
<channel id="valve" typeId="valve-channel" />
<channel id="battery" typeId="battery-channel" />
<channel id="mode" typeId="mode-channel" />
<channel id="actual_temp" typeId="actual_temp-channel" />
<channel id="set_temp" typeId="set_temp-channel" />
<channel id="valve" typeId="valve" />
<channel id="battery" typeId="battery" />
<channel id="mode" typeId="mode" />
<channel id="actual_temp" typeId="actual_temp" />
<channel id="set_temp" typeId="set_temp" />
</channels>

<config-description>
Expand All @@ -40,8 +40,8 @@
<description>MaxCube All Switches (EcoSwitch, Pushbutton/ShutterContact)</description>

<channels>
<channel id="state" typeId="switch_state-channel" />
<channel id="battery" typeId="battery-channel" />
<channel id="state" typeId="switch_state" />
<channel id="battery" typeId="battery" />

</channels>

Expand All @@ -54,40 +54,40 @@
</config-description>
</thing-type>

<channel-type id="valve-channel">
<channel-type id="valve">
<item-type>Number</item-type>
<label>Valve Position Channel</label>
<label>Valve Position</label>
<description>Thermostat Valve Position</description>
</channel-type>

<channel-type id="battery-channel">
<channel-type id="battery">
<item-type>String</item-type>
<label>Battery Level Channel</label>
<label>Battery Level</label>
<description>Battery charge Level</description>
</channel-type>

<channel-type id="mode-channel">
<channel-type id="mode">
<item-type>String</item-type>
<label>Mode Channel</label>
<label>Mode</label>
<description>Thermostat Mode Setting</description>
</channel-type>

<channel-type id="actual_temp-channel">
<channel-type id="actual_temp">
<item-type>Number</item-type>
<label>Actual Temperature Channel</label>
<label>Actual Temperature</label>
<description>Actual measured room temperature</description>
</channel-type>

<channel-type id="set_temp-channel">
<channel-type id="set_temp">
<item-type>Number</item-type>
<label>Set Temperature Channel</label>
<label>Set Temperature</label>
<description>Thermostat temperature setpoint</description>
</channel-type>


<channel-type id="switch_state-channel">
<channel-type id="switch_state">
<item-type>Contact</item-type>
<label>Switch state Channel</label>
<label>Switch state</label>
<description>Switch state information</description>
</channel-type>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class MaxCubeBinding {
public final static ThingTypeUID SWITCH_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_SWITCH);

// List of all Thing Type UIDs
public final static ThingTypeUID CubeBridge_THING_TYPE = new ThingTypeUID(BINDING_ID, BRIDGE_MAXCUBE);
public final static ThingTypeUID CUBEBRIDGE_THING_TYPE = new ThingTypeUID(BINDING_ID, BRIDGE_MAXCUBE);

// List of all Channel ids
public final static String CHANNEL_VALVE = "valve";
Expand All @@ -46,12 +46,12 @@ public class MaxCubeBinding {
public final static String CHANNEL_SWITCH_STATE = "state";

public final static Collection<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Lists.newArrayList(
HEATHINGTHERMOSTAT_THING_TYPE, SWITCH_THING_TYPE, CubeBridge_THING_TYPE);
HEATHINGTHERMOSTAT_THING_TYPE, SWITCH_THING_TYPE, CUBEBRIDGE_THING_TYPE);

public final static Set<ThingTypeUID> SUPPORTED_DEVICE_THING_TYPES_UIDS =ImmutableSet.of(
HEATHINGTHERMOSTAT_THING_TYPE,SWITCH_THING_TYPE);


public final static Set<ThingTypeUID> SUPPORTED_BRIDGE_THING_TYPES_UIDS =ImmutableSet.of(
CubeBridge_THING_TYPE);
CUBEBRIDGE_THING_TYPE);
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ public void sendCommands() {
* @return the raw message text as ArrayList of String
*/
private ArrayList<String> getRawMessage() {
//Fake a message for testing purposes
if (ipAddress.equals( "fakeMessage")){
connectionEstablished = true;
logger.warn("Content based on faked data!!");
return getRawFAKEMessage();
}
synchronized (MaxCubeBridge.class){
Socket socket = null;
BufferedReader reader = null;
Expand Down Expand Up @@ -445,19 +439,4 @@ public void executeCommand(SendCommand sendCommand) {
}
}}




private ArrayList<String> getRawFAKEMessage(){
ArrayList<String> rawMessage = new ArrayList<String> () ;
rawMessage.add ("H:KEQ0565026,0b5951,0113,00000000,72aeba8b,03,32,0e090b,1127,03,0000");
rawMessage.add ("M:00,01,VgICAQhiYWRrYW1lcgsNowIMU3R1ZGVlcmthbWVyB7bnAgILDaNLRVEwNTQ0MjQyEUJhZGthbWVyIFJhZGlhdG9yAQEHtudLRVEwMTQ1MTcyFVJhZGlhdG9yIFN0dWRlZXJrYW1lcgIB");
rawMessage.add ("C:0b5951,7QtZUQATAf9LRVEwNTY1MDI2AQsABEAAAAAAAAAAAP///////////////////////////wsABEAAAAAAAAAAQf///////////////////////////2h0dHA6Ly9tYXguZXEtMy5kZTo4MC9jdWJlADAvbG9va3VwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAENFVAAACgADAAAOEENFU1QAAwACAAAcIA==");
rawMessage.add ("C:0b0da3,0gsNowIBEABLRVEwNTQ0MjQyLCQ9CQcYAzAM/wBIYViRSP1ZFE0gTSBNIEUgRSBFIEUgRSBFIEhhWJFQ/VkVUSBRIFEgRSBFIEUgRSBFIEUgSFBYWkj+WRRNIE0gTSBFIEUgRSBFIEUgRSBIUFhaSP5ZFE0gTSBNIEUgRSBFIEUgRSBFIEhQWFpI/lkUTSBNIE0gRSBFIEUgRSBFIEUgSFBYWkj+WRRNIE0gTSBFIEUgRSBFIEUgRSBIUFhaSP5ZFE0gTSBNIEUgRSBFIEUgRSBFIA==");
rawMessage.add ("C:07b6e7,0ge25wECGP9LRVEwMTQ1MTcyKyE9CQcYAzAM/wBEflUaRSBFIEUgRSBFIEUgRSBFIEUgRSBFIER+VRpFIEUgRSBFIEUgRSBFIEUgRSBFIEUgRFRUcEjSVRJJIEkgSSBFIEUgRSBFIEUgRSBEVFRwSNJVEkkgSSBJIEUgRSBFIEUgRSBFIERUVG9U01URSSBJIEkgRSBFIEUgRSBFIEUgRFRUcEjSVRJJIEkgSSBFIEUgRSBFIEUgRSBEVFRwSNJVEkkgSSBJIEUgRSBFIEUgRSBFIA==");
rawMessage.add ("L:CwsNowkSGQAJAAAACwe25wkSGWAvAAAA");
return rawMessage;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ private void discoverCube() {
if(cubeSerialNumber!=null) {
logger.debug("Adding new Max!Cube Lan Gateway on {} with id '{}' to Smarthome inbox", ipAddress, cubeSerialNumber);

ThingUID uid = new ThingUID( MaxCubeBinding.CubeBridge_THING_TYPE, "MaxCube_" + cubeSerialNumber);
ThingUID uid = new ThingUID( MaxCubeBinding.CUBEBRIDGE_THING_TYPE, "MaxCube_" + cubeSerialNumber);
if(uid!=null) {
DiscoveryResult result = DiscoveryResultBuilder.create(uid)
.withProperty(MaxCubeConfiguration.SERIAL_NUMBER,cubeSerialNumber)
.withLabel("MaxCube LAN Gateway on " + ipAddress )
.withLabel("MaxCube LAN Gateway (" + cubeSerialNumber + ")" )
.build();
thingDiscovered (result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void onDeviceAdded(MaxCubeBridge bridge, Device device) {
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID)
.withProperty(MaxCubeConfiguration.SERIAL_NUMBER, device.getSerialNumber())
.withBridge(bridgeUID)
.withLabel( device.getType() + " " + device.getName() + " (serial: " + device.getSerialNumber() +")")
.withLabel( device.getType() + ": " + device.getName() + " (" + device.getSerialNumber() +")")
.build();
thingDiscovered(discoveryResult);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MaxCubeHandlerFactory extends BaseThingHandlerFactory {
public Thing createThing(ThingTypeUID thingTypeUID, Configuration configuration,
ThingUID thingUID, ThingUID bridgeUID) {

if (MaxCubeBinding.CubeBridge_THING_TYPE.equals(thingTypeUID)) {
if (MaxCubeBinding.CUBEBRIDGE_THING_TYPE.equals(thingTypeUID)) {
ThingUID cubeBridgeUID = getBridgeThingUID(thingTypeUID, thingUID, configuration);
return super.createThing(thingTypeUID, configuration, cubeBridgeUID, null);
}
Expand Down Expand Up @@ -106,7 +106,7 @@ protected void removeHandler(ThingHandler thingHandler) {

@Override
protected ThingHandler createHandler(Thing thing) {
if (thing.getThingTypeUID().equals(MaxCubeBinding.CubeBridge_THING_TYPE)) {
if (thing.getThingTypeUID().equals(MaxCubeBinding.CUBEBRIDGE_THING_TYPE)) {
MaxCubeBridgeHandler handler = new MaxCubeBridgeHandler((Bridge) thing);
registerDeviceDiscoveryService(handler);
return handler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ public MaxCubeBridgeHandler(Bridge br) {
private Runnable pollingRunnable = new Runnable() {
@Override
public void run() {
Thread.currentThread().setName("maxcube-sendcommand");
refreshData(); }
};
private ScheduledFuture<?> sendCommandJob;
private long sendCommandInterval = 10000;
private Runnable sendCommandRunnable = new Runnable() {
@Override
public void run() {
Thread.currentThread().setName("maxcube-datarefresh");
sendCommands(); }
};
@Override
Expand Down Expand Up @@ -148,11 +150,8 @@ private synchronized void refreshData() {
if (bridge !=null){
bridge.refreshData();
if (bridge.isConnectionEstablished()){
if ( previousOnline == false) {
updateStatus(ThingStatus.ONLINE);
previousOnline = bridge.isConnectionEstablished();
}

updateStatus(ThingStatus.ONLINE);
previousOnline = true;
devices = bridge.getDevices();
for (Device di : devices){
if (lastActiveDevices.contains(di.getSerialNumber())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public S_Command(String rfAddress, int roomId, double setpointTemperature) {
// 10 = Temporarily

bits[7] = false; // A (MSB)
bits[6] = true; // B
bits[6] = false; // B
}

/**
Expand Down

0 comments on commit 45e8433

Please sign in to comment.