use of org.openhab.binding.pilight.internal.communication.Action in project openhab1-addons by openhab.
the class PilightBinding method createUpdateCommand.
private Action createUpdateCommand(Command command, PilightBindingConfig config) {
Action action = new Action(Action.ACTION_CONTROL);
Code code = new Code();
code.setDevice(config.getDevice());
if (command instanceof OnOffType) {
setOnOffValue((OnOffType) command, code);
} else if (command instanceof PercentType) {
setDimmerValue((PercentType) command, code);
} else {
logger.error("Only OnOffType and PercentType can be changed by the pilight binding");
return null;
}
action.setCode(code);
return action;
}
use of org.openhab.binding.pilight.internal.communication.Action in project openhab1-addons by openhab.
the class PilightConnector method internalRefreshConfig.
private void internalRefreshConfig() throws JsonGenerationException, JsonMappingException, IOException {
if (!updatingConfig) {
updatingConfig = true;
logger.info("Updating pilight config");
Socket socket = connection.getSocket();
outputMapper.writeValue(socket.getOutputStream(), new Action(Action.ACTION_REQUEST_CONFIG));
}
}
use of org.openhab.binding.pilight.internal.communication.Action in project openhab1-addons by openhab.
the class PilightBinding method internalReceiveCommand.
/**
* @{inheritDoc}
*/
@Override
protected void internalReceiveCommand(String itemName, Command command) {
PilightBindingProvider provider = findFirstMatchingBindingProvider(itemName);
PilightBindingConfig config = provider.getBindingConfig(itemName);
PilightConnection connection = connections.get(config.getInstance());
Action action = createUpdateCommand(command, config);
if (action != null) {
sendUpdate(action, connection);
}
}
Aggregations