use of org.openhab.binding.yamahareceiver.internal.hardware.YamahaReceiverState in project openhab1-addons by openhab.
the class YamahaReceiverBinding method sendUpdates.
private void sendUpdates(YamahaReceiverProxy receiverProxy, String deviceUid) {
// Get all item configurations belonging to this proxy
Collection<YamahaReceiverBindingConfig> configs = getDeviceConfigs(deviceUid);
try {
for (Zone zone : Zone.values()) {
// Poll the state from the device
YamahaReceiverState state = receiverProxy.getState(zone);
// Create state updates
State powerUpdate = state.isPower() ? OnOffType.ON : OnOffType.OFF;
State muteUpdate = state.isMute() ? OnOffType.ON : OnOffType.OFF;
State inputUpdate = new StringType(state.getInput());
State surroundUpdate = new StringType(state.getSurroundProgram());
State updateVolumeDb = new DecimalType(state.getVolume());
State updateVolumePercent = new PercentType((int) dbToPercent(state.getVolume()));
// Send updates
sendUpdate(configs, zone, BindingType.power, powerUpdate);
sendUpdate(configs, zone, BindingType.mute, muteUpdate);
sendUpdate(configs, zone, BindingType.input, inputUpdate);
sendUpdate(configs, zone, BindingType.surroundProgram, surroundUpdate);
sendUpdate(configs, zone, BindingType.volumePercent, updateVolumePercent);
sendUpdate(configs, zone, BindingType.volumeDb, updateVolumeDb);
}
} catch (IOException e) {
logger.warn("Cannot communicate with " + receiverProxy.getHost());
}
}
Aggregations