Search in sources :

Example 11 with UDAServiceId

use of org.teleal.cling.model.types.UDAServiceId in project openhab1-addons by openhab.

the class SonosZonePlayer method updateZoneInfo.

public boolean updateZoneInfo() {
    if (stateMap != null && isConfigured()) {
        Service service = device.findService(new UDAServiceId("DeviceProperties"));
        Action action = service.getAction("GetZoneInfo");
        ActionInvocation invocation = new ActionInvocation(action);
        executeActionInvocation(invocation);
        Service anotherservice = device.findService(new UDAServiceId("DeviceProperties"));
        Action anotheraction = service.getAction("GetZoneAttributes");
        ActionInvocation anotherinvocation = new ActionInvocation(anotheraction);
        executeActionInvocation(anotherinvocation);
        return true;
    } else {
        return false;
    }
}
Also used : Action(org.teleal.cling.model.meta.Action) ActionInvocation(org.teleal.cling.model.action.ActionInvocation) Service(org.teleal.cling.model.meta.Service) UpnpService(org.teleal.cling.UpnpService) UDAServiceId(org.teleal.cling.model.types.UDAServiceId)

Example 12 with UDAServiceId

use of org.teleal.cling.model.types.UDAServiceId in project openhab1-addons by openhab.

the class SonosZonePlayer method play.

public boolean play() {
    if (isConfigured()) {
        Service service = device.findService(new UDAServiceId("AVTransport"));
        Action action = service.getAction("Play");
        ActionInvocation invocation = new ActionInvocation(action);
        invocation.setInput("Speed", "1");
        executeActionInvocation(invocation);
        return true;
    } else {
        return false;
    }
}
Also used : Action(org.teleal.cling.model.meta.Action) ActionInvocation(org.teleal.cling.model.action.ActionInvocation) Service(org.teleal.cling.model.meta.Service) UpnpService(org.teleal.cling.UpnpService) UDAServiceId(org.teleal.cling.model.types.UDAServiceId)

Example 13 with UDAServiceId

use of org.teleal.cling.model.types.UDAServiceId in project openhab1-addons by openhab.

the class SonosZonePlayer method updateLed.

public boolean updateLed() {
    if (isConfigured()) {
        Service service = device.findService(new UDAServiceId("DeviceProperties"));
        Action action = service.getAction("GetLEDState");
        ActionInvocation invocation = new ActionInvocation(action);
        executeActionInvocation(invocation);
        return true;
    } else {
        return false;
    }
}
Also used : Action(org.teleal.cling.model.meta.Action) ActionInvocation(org.teleal.cling.model.action.ActionInvocation) Service(org.teleal.cling.model.meta.Service) UpnpService(org.teleal.cling.UpnpService) UDAServiceId(org.teleal.cling.model.types.UDAServiceId)

Example 14 with UDAServiceId

use of org.teleal.cling.model.types.UDAServiceId in project openhab1-addons by openhab.

the class SonosZonePlayer method setCurrentURI.

public boolean setCurrentURI(String URI, String URIMetaData) {
    if (URI != null && URIMetaData != null && isConfigured()) {
        Service service = device.findService(new UDAServiceId("AVTransport"));
        Action action = service.getAction("SetAVTransportURI");
        ActionInvocation invocation = new ActionInvocation(action);
        try {
            invocation.setInput("InstanceID", "0");
            invocation.setInput("CurrentURI", URI);
            invocation.setInput("CurrentURIMetaData", URIMetaData);
        } 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;
    }
}
Also used : InvalidValueException(org.teleal.cling.model.types.InvalidValueException) Action(org.teleal.cling.model.meta.Action) ActionInvocation(org.teleal.cling.model.action.ActionInvocation) Service(org.teleal.cling.model.meta.Service) UpnpService(org.teleal.cling.UpnpService) UDAServiceId(org.teleal.cling.model.types.UDAServiceId)

Example 15 with UDAServiceId

use of org.teleal.cling.model.types.UDAServiceId in project openhab1-addons by openhab.

the class SonosZonePlayer method snoozeAlarm.

public boolean snoozeAlarm(int minutes) {
    if (isAlarmRunning() && isConfigured()) {
        Service service = device.findService(new UDAServiceId("AVTransport"));
        Action action = service.getAction("SnoozeAlarm");
        ActionInvocation invocation = new ActionInvocation(action);
        Period snoozePeriod = Period.minutes(minutes);
        PeriodFormatter pFormatter = new PeriodFormatterBuilder().printZeroAlways().appendHours().appendSeparator(":").appendMinutes().appendSeparator(":").appendSeconds().toFormatter();
        try {
            invocation.setInput("Duration", pFormatter.print(snoozePeriod));
        } 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 {
        logger.warn("There is no alarm running on {} ", this);
        return false;
    }
}
Also used : InvalidValueException(org.teleal.cling.model.types.InvalidValueException) Action(org.teleal.cling.model.meta.Action) PeriodFormatterBuilder(org.joda.time.format.PeriodFormatterBuilder) PeriodFormatter(org.joda.time.format.PeriodFormatter) ActionInvocation(org.teleal.cling.model.action.ActionInvocation) Service(org.teleal.cling.model.meta.Service) UpnpService(org.teleal.cling.UpnpService) Period(org.joda.time.Period) UDAServiceId(org.teleal.cling.model.types.UDAServiceId)

Aggregations

UDAServiceId (org.teleal.cling.model.types.UDAServiceId)27 UpnpService (org.teleal.cling.UpnpService)26 Service (org.teleal.cling.model.meta.Service)26 ActionInvocation (org.teleal.cling.model.action.ActionInvocation)25 Action (org.teleal.cling.model.meta.Action)25 InvalidValueException (org.teleal.cling.model.types.InvalidValueException)12 SAXException (org.xml.sax.SAXException)3 PeriodFormatter (org.joda.time.format.PeriodFormatter)2 PeriodFormatterBuilder (org.joda.time.format.PeriodFormatterBuilder)2 SonosCommandType (org.openhab.binding.sonos.SonosCommandType)2 UnsignedIntegerFourBytes (org.teleal.cling.model.types.UnsignedIntegerFourBytes)2 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 IllegalClassException (org.apache.commons.lang.IllegalClassException)1 Period (org.joda.time.Period)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1 SonosBindingProvider (org.openhab.binding.sonos.SonosBindingProvider)1 Command (org.openhab.core.types.Command)1 BindingConfigParseException (org.openhab.model.item.binding.BindingConfigParseException)1