use of org.teleal.cling.model.action.ActionInvocation in project openhab1-addons by openhab.
the class SonosZonePlayer method removeAllTracksFromQueue.
/**
* Clear all scheduled music from the current queue.
*
* @return true if no error occurred.
*/
public boolean removeAllTracksFromQueue() {
if (!isConfigured) {
return false;
}
Service service = device.findService(new UDAServiceId("AVTransport"));
Action action = service.getAction("RemoveAllTracksFromQueue");
ActionInvocation invocation = new ActionInvocation(action);
try {
invocation.setInput("InstanceID", "0");
} catch (InvalidValueException ex) {
logger.error("Action Invalid Value Exception {}", ex.getMessage());
} catch (NumberFormatException ex) {
logger.error("Action Invalid Value Format Exception {}", ex.getMessage());
}
executeActionInvocation(invocation);
return true;
}
use of org.teleal.cling.model.action.ActionInvocation in project openhab1-addons by openhab.
the class SonosZonePlayer method setMute.
public boolean setMute(String string) {
if (string != null && isConfigured()) {
Service service = device.findService(new UDAServiceId("RenderingControl"));
Action action = service.getAction("SetMute");
ActionInvocation invocation = new ActionInvocation(action);
try {
invocation.setInput("Channel", "Master");
if (string.equals("ON") || string.equals("OPEN") || string.equals("UP")) {
invocation.setInput("DesiredMute", "True");
} else if (string.equals("OFF") || string.equals("CLOSED") || string.equals("DOWN")) {
invocation.setInput("DesiredMute", "False");
} else {
return false;
}
} catch (InvalidValueException ex) {
logger.error("Action Invalid Value Exception {}", ex.getMessage());
} catch (NumberFormatException ex) {
logger.error("Action Invalid Value Format Exception {}", ex.getMessage());
}
executeActionInvocation(invocation);
return true;
} else {
return false;
}
}
use of org.teleal.cling.model.action.ActionInvocation in project openhab1-addons by openhab.
the class SonosZonePlayer method previous.
public boolean previous() {
if (isConfigured()) {
Service service = device.findService(new UDAServiceId("AVTransport"));
Action action = service.getAction("Previous");
ActionInvocation invocation = new ActionInvocation(action);
executeActionInvocation(invocation);
return true;
} else {
return false;
}
}
use of org.teleal.cling.model.action.ActionInvocation in project openhab1-addons by openhab.
the class SonosZonePlayer method updateAlarm.
public boolean updateAlarm(SonosAlarm alarm) {
if (alarm != null && isConfigured()) {
Service service = device.findService(new UDAServiceId("AlarmClock"));
Action action = service.getAction("ListAlarms");
ActionInvocation invocation = new ActionInvocation(action);
DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm:ss");
PeriodFormatter pFormatter = new PeriodFormatterBuilder().printZeroAlways().appendHours().appendSeparator(":").appendMinutes().appendSeparator(":").appendSeconds().toFormatter();
try {
invocation.setInput("ID", Integer.toString(alarm.getID()));
invocation.setInput("StartLocalTime", formatter.print(alarm.getStartTime()));
invocation.setInput("Duration", pFormatter.print(alarm.getDuration()));
invocation.setInput("Recurrence", alarm.getRecurrence());
invocation.setInput("RoomUUID", alarm.getRoomUUID());
invocation.setInput("ProgramURI", alarm.getProgramURI());
invocation.setInput("ProgramMetaData", alarm.getProgramMetaData());
invocation.setInput("PlayMode", alarm.getPlayMode());
invocation.setInput("Volume", Integer.toString(alarm.getVolume()));
if (alarm.getIncludeLinkedZones()) {
invocation.setInput("IncludeLinkedZones", "1");
} else {
invocation.setInput("IncludeLinkedZones", "0");
}
if (alarm.getEnabled()) {
invocation.setInput("Enabled", "1");
} else {
invocation.setInput("Enabled", "0");
}
} catch (InvalidValueException ex) {
logger.error("Action Invalid Value Exception {}", ex.getMessage());
} catch (NumberFormatException ex) {
logger.error("Action Invalid Value Format Exception {}", ex.getMessage());
}
executeActionInvocation(invocation);
return true;
} else {
return false;
}
}
use of org.teleal.cling.model.action.ActionInvocation in project openhab1-addons by openhab.
the class SonosZonePlayer method stop.
public boolean stop() {
if (isConfigured()) {
Service service = device.findService(new UDAServiceId("AVTransport"));
Action action = service.getAction("Stop");
ActionInvocation invocation = new ActionInvocation(action);
executeActionInvocation(invocation);
return true;
} else {
return false;
}
}
Aggregations