[SOLVED] Trying to implement ThingActions into binding

(David Masshardt) #1

I’am trying to implement ThingActions into the Onkyo binding, but I’m always getting an error that the action is not found:

Rule ‘Test Switch’: ‘sendRawCommand’ is not a member of ‘org.eclipse.smarthome.core.thing.binding.ThingActions’; line 6, column 9, length 35

Here is the code of my implementation:

 * Copyright (c) 2010-2019 Contributors to the openHAB project
 * See the NOTICE file(s) distributed with this work for additional
 * information.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 * SPDX-License-Identifier: EPL-2.0
package org.openhab.binding.onkyo.internal.automation.modules;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.thing.binding.ThingActions;
import org.eclipse.smarthome.core.thing.binding.ThingActionsScope;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.openhab.binding.onkyo.internal.eiscp.EiscpCommand;
import org.openhab.binding.onkyo.internal.handler.OnkyoHandler;
import org.openhab.core.automation.annotation.ActionInput;
import org.openhab.core.automation.annotation.RuleAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

 * Some automation actions to be used with a {@link OnkyoThingActionsService}
 * @author David Masshardt - initial contribution
@ThingActionsScope(name = "onkyo")
public class OnkyoThingActionsService implements ThingActions {

    private final Logger logger = LoggerFactory.getLogger(OnkyoThingActionsService.class);

    private @Nullable OnkyoHandler handler;

    @RuleAction(label = "Onkyo sendRawCommand", description = "Action that sends raw command to the receiver")
    public void sendRawCommand(@ActionInput(name = "rawCommand") @Nullable String rawCommand) {
        logger.debug("sendRawCommand called with raw command: {}", rawCommand);

    public void setThingHandler(@Nullable ThingHandler handler) {
        if (handler instanceof OnkyoHandler) {
            this.handler = (OnkyoHandler) handler;

    public @Nullable ThingHandler getThingHandler() {
        return this.handler;


I’ve also added the getServices method to the binding handler:

    public Collection<Class<? extends ThingHandlerService>> getServices() {
        return Collections.singletonList(OnkyoThingActionsService.class);

And this is my test rule:

rule "Test Switch"
        Item SW_Test changed
        val onkyoActions = getActions("onkyo","onkyo:TX-NR818:93b02aca-832a-cab9-6a23-ca0983b98a33")

What am I doing wrong? I copied most of the code from the MQTT binding and there the method call works.

(Hilbrand Bouwkamp) #2

(David Masshardt) #3

Thanks for the quick help, it is working now!

(David Graeff) #4

It’s so cool that more and more bindings are picking this up. As soon as we officially release the new rule engine, there will be plenty of actions it looks like.