Search in sources :

Example 1 with HmInterface

use of org.eclipse.smarthome.binding.homematic.internal.model.HmInterface in project smarthome by eclipse.

the class AbstractHomematicGateway method startServers.

/**
 * Starts the Homematic RPC server.
 */
private synchronized void startServers() throws IOException {
    for (TransferMode mode : availableInterfaces.values()) {
        if (!rpcServers.containsKey(mode)) {
            RpcServer rpcServer = mode == TransferMode.XML_RPC ? new XmlRpcServer(this, config) : new BinRpcServer(this, config);
            rpcServers.put(mode, rpcServer);
            rpcServer.start();
        }
    }
    for (HmInterface hmInterface : availableInterfaces.keySet()) {
        getRpcClient(hmInterface).init(hmInterface, hmInterface.toString() + "-" + id);
    }
}
Also used : BinRpcServer(org.eclipse.smarthome.binding.homematic.internal.communicator.server.BinRpcServer) BinRpcServer(org.eclipse.smarthome.binding.homematic.internal.communicator.server.BinRpcServer) RpcServer(org.eclipse.smarthome.binding.homematic.internal.communicator.server.RpcServer) XmlRpcServer(org.eclipse.smarthome.binding.homematic.internal.communicator.server.XmlRpcServer) TransferMode(org.eclipse.smarthome.binding.homematic.internal.communicator.client.TransferMode) XmlRpcServer(org.eclipse.smarthome.binding.homematic.internal.communicator.server.XmlRpcServer) HmInterface(org.eclipse.smarthome.binding.homematic.internal.model.HmInterface)

Example 2 with HmInterface

use of org.eclipse.smarthome.binding.homematic.internal.model.HmInterface in project smarthome by eclipse.

the class AbstractHomematicGateway method setInstallMode.

@Override
public void setInstallMode(boolean enable, int seconds) throws IOException {
    HmDevice gwExtrasHm = devices.get(HmDevice.ADDRESS_GATEWAY_EXTRAS);
    if (gwExtrasHm != null) {
        // since the homematic virtual device exist: try setting install mode via its dataPoints
        HmDatapoint installModeDataPoint = null;
        HmDatapoint installModeDurationDataPoint = null;
        // collect virtual datapoints to be accessed
        HmChannel hmChannel = gwExtrasHm.getChannel(HmChannel.CHANNEL_NUMBER_EXTRAS);
        HmDatapointInfo installModeDurationDataPointInfo = new HmDatapointInfo(HmParamsetType.VALUES, hmChannel, HomematicConstants.VIRTUAL_DATAPOINT_NAME_INSTALL_MODE_DURATION);
        if (enable) {
            installModeDurationDataPoint = hmChannel.getDatapoint(installModeDurationDataPointInfo);
        }
        HmDatapointInfo installModeDataPointInfo = new HmDatapointInfo(HmParamsetType.VALUES, hmChannel, HomematicConstants.VIRTUAL_DATAPOINT_NAME_INSTALL_MODE);
        installModeDataPoint = hmChannel.getDatapoint(installModeDataPointInfo);
        // first set duration on the datapoint
        if (installModeDurationDataPoint != null) {
            try {
                VirtualDatapointHandler handler = getVirtualDatapointHandler(installModeDurationDataPoint, null);
                handler.handleCommand(this, installModeDurationDataPoint, new HmDatapointConfig(), seconds);
                // notify thing if exists
                gatewayAdapter.onStateUpdated(installModeDurationDataPoint);
            } catch (HomematicClientException ex) {
                logger.warn("Failed to send datapoint {}", installModeDurationDataPoint, ex);
            }
        }
        // now that the duration is set, we can enable / disable
        if (installModeDataPoint != null) {
            try {
                VirtualDatapointHandler handler = getVirtualDatapointHandler(installModeDataPoint, null);
                handler.handleCommand(this, installModeDataPoint, new HmDatapointConfig(), enable);
                // notify thing if exists
                gatewayAdapter.onStateUpdated(installModeDataPoint);
                return;
            } catch (HomematicClientException ex) {
                logger.warn("Failed to send datapoint {}", installModeDataPoint, ex);
            }
        }
    }
    // no gwExtrasHm available (or previous approach failed), therefore use rpc client directly
    for (HmInterface hmInterface : availableInterfaces.keySet()) {
        if (hmInterface == HmInterface.RF || hmInterface == HmInterface.CUXD) {
            getRpcClient(hmInterface).setInstallMode(hmInterface, enable, seconds);
        }
    }
}
Also used : HmDevice(org.eclipse.smarthome.binding.homematic.internal.model.HmDevice) HmDatapointConfig(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointConfig) HomematicClientException(org.eclipse.smarthome.binding.homematic.internal.misc.HomematicClientException) HmInterface(org.eclipse.smarthome.binding.homematic.internal.model.HmInterface) HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) HmDatapointInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint) ReloadFromGatewayVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ReloadFromGatewayVirtualDatapointHandler) RssiVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.RssiVirtualDatapointHandler) ReloadAllFromGatewayVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ReloadAllFromGatewayVirtualDatapointHandler) StateContactVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.StateContactVirtualDatapointHandler) SignalStrengthVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.SignalStrengthVirtualDatapointHandler) ButtonVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ButtonVirtualDatapointHandler) FirmwareVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.FirmwareVirtualDatapointHandler) ReloadRssiVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ReloadRssiVirtualDatapointHandler) DeleteDeviceModeVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DeleteDeviceModeVirtualDatapointHandler) VirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.VirtualDatapointHandler) DeleteDeviceVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DeleteDeviceVirtualDatapointHandler) HmwIoModuleVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.HmwIoModuleVirtualDatapointHandler) OnTimeAutomaticVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.OnTimeAutomaticVirtualDatapointHandler) BatteryTypeVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.BatteryTypeVirtualDatapointHandler) DisplayOptionsVirtualDatapointHandler(org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DisplayOptionsVirtualDatapointHandler)

Example 3 with HmInterface

use of org.eclipse.smarthome.binding.homematic.internal.model.HmInterface in project smarthome by eclipse.

the class AbstractHomematicGateway method getDeviceDescriptions.

/**
 * Loads all device descriptions from the gateway.
 */
private List<HmDevice> getDeviceDescriptions() throws IOException {
    List<HmDevice> deviceDescriptions = new ArrayList<HmDevice>();
    for (HmInterface hmInterface : availableInterfaces.keySet()) {
        deviceDescriptions.addAll(getRpcClient(hmInterface).listDevices(hmInterface));
    }
    if (!cancelLoadAllMetadata) {
        deviceDescriptions.add(createGatewayDevice());
        loadDeviceNames(deviceDescriptions);
    }
    return deviceDescriptions;
}
Also used : HmDevice(org.eclipse.smarthome.binding.homematic.internal.model.HmDevice) ArrayList(java.util.ArrayList) HmInterface(org.eclipse.smarthome.binding.homematic.internal.model.HmInterface)

Example 4 with HmInterface

use of org.eclipse.smarthome.binding.homematic.internal.model.HmInterface in project smarthome by eclipse.

the class InstallModeVirtualDatapoint method handleCommand.

@Override
public void handleCommand(VirtualGateway gateway, HmDatapoint dp, HmDatapointConfig dpConfig, Object value) throws IOException, HomematicClientException {
    dp.setValue(value);
    boolean enable = MiscUtils.isTrueValue(value);
    int duration = getDuration(dp.getChannel());
    if (enable) {
        gateway.disableDatapoint(dp, duration);
    }
    HmInterface hmInterface = dp.getChannel().getDevice().getHmInterface();
    gateway.getRpcClient(hmInterface).setInstallMode(hmInterface, enable, duration);
}
Also used : HmInterface(org.eclipse.smarthome.binding.homematic.internal.model.HmInterface) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 5 with HmInterface

use of org.eclipse.smarthome.binding.homematic.internal.model.HmInterface in project smarthome by eclipse.

the class AbstractHomematicGateway method loadRssiValues.

@Override
public void loadRssiValues() throws IOException {
    for (HmInterface hmInterface : availableInterfaces.keySet()) {
        if (hmInterface == HmInterface.RF || hmInterface == HmInterface.CUXD) {
            List<HmRssiInfo> rssiInfos = getRpcClient(hmInterface).loadRssiInfo(hmInterface);
            for (HmRssiInfo hmRssiInfo : rssiInfos) {
                updateRssiInfo(hmRssiInfo.getAddress(), DATAPOINT_NAME_RSSI_DEVICE, hmRssiInfo.getDevice());
                updateRssiInfo(hmRssiInfo.getAddress(), DATAPOINT_NAME_RSSI_PEER, hmRssiInfo.getPeer());
            }
        }
    }
}
Also used : HmRssiInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmRssiInfo) HmInterface(org.eclipse.smarthome.binding.homematic.internal.model.HmInterface)

Aggregations

HmInterface (org.eclipse.smarthome.binding.homematic.internal.model.HmInterface)6 TransferMode (org.eclipse.smarthome.binding.homematic.internal.communicator.client.TransferMode)2 HmDatapoint (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)2 HmDevice (org.eclipse.smarthome.binding.homematic.internal.model.HmDevice)2 ArrayList (java.util.ArrayList)1 BinRpcServer (org.eclipse.smarthome.binding.homematic.internal.communicator.server.BinRpcServer)1 RpcServer (org.eclipse.smarthome.binding.homematic.internal.communicator.server.RpcServer)1 XmlRpcServer (org.eclipse.smarthome.binding.homematic.internal.communicator.server.XmlRpcServer)1 BatteryTypeVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.BatteryTypeVirtualDatapointHandler)1 ButtonVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ButtonVirtualDatapointHandler)1 DeleteDeviceModeVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DeleteDeviceModeVirtualDatapointHandler)1 DeleteDeviceVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DeleteDeviceVirtualDatapointHandler)1 DisplayOptionsVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DisplayOptionsVirtualDatapointHandler)1 FirmwareVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.FirmwareVirtualDatapointHandler)1 HmwIoModuleVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.HmwIoModuleVirtualDatapointHandler)1 OnTimeAutomaticVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.OnTimeAutomaticVirtualDatapointHandler)1 ReloadAllFromGatewayVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ReloadAllFromGatewayVirtualDatapointHandler)1 ReloadFromGatewayVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ReloadFromGatewayVirtualDatapointHandler)1 ReloadRssiVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ReloadRssiVirtualDatapointHandler)1 RssiVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.RssiVirtualDatapointHandler)1