Search in sources :

Example 1 with OpenSprinklerBindingProvider

use of org.openhab.binding.opensprinkler.OpenSprinklerBindingProvider in project openhab1-addons by openhab.

the class OpenSprinklerBinding method internalReceiveCommand.

/**
     * @{inheritDoc}
     */
@Override
protected void internalReceiveCommand(String itemName, Command command) {
    if (command instanceof OnOffType) {
        final OnOffType switchCommand = (OnOffType) command;
        final OpenSprinklerBindingProvider bindingProvider = findFirstMatchingBindingProvider(itemName, command);
        final int station = bindingProvider.getStationNumber(itemName);
        if (station < 0 || station >= numberOfStations) {
            logger.warn("Station " + station + " is not in the valid [" + 0 + ".." + numberOfStations + "] range");
            return;
        }
        switch(switchCommand) {
            case ON:
                openSprinkler.openStation(station);
                break;
            case OFF:
                openSprinkler.closeStation(station);
                break;
        }
        return;
    }
    if (command instanceof OpenClosedType) {
        // abort processing
        return;
    }
    logger.debug("Provided command " + command + " is not of type 'OnOffType' or 'OpenClosedType'");
}
Also used : OpenSprinklerBindingProvider(org.openhab.binding.opensprinkler.OpenSprinklerBindingProvider) OnOffType(org.openhab.core.library.types.OnOffType) OpenClosedType(org.openhab.core.library.types.OpenClosedType)

Aggregations

OpenSprinklerBindingProvider (org.openhab.binding.opensprinkler.OpenSprinklerBindingProvider)1 OnOffType (org.openhab.core.library.types.OnOffType)1 OpenClosedType (org.openhab.core.library.types.OpenClosedType)1