2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.io.imperihome.internal.action;
15 import org.openhab.core.events.EventPublisher;
16 import org.openhab.core.items.Item;
17 import org.openhab.core.items.events.ItemCommandEvent;
18 import org.openhab.core.items.events.ItemEventFactory;
19 import org.openhab.core.library.types.PercentType;
20 import org.openhab.io.imperihome.internal.model.device.AbstractDevice;
23 * Action setting percentage level, e.g. dimmer.
25 * @author Pepijn de Geus - Initial contribution
27 public class SetLevelAction extends Action {
29 public SetLevelAction(EventPublisher eventPublisher) {
30 super(eventPublisher);
34 public boolean supports(AbstractDevice device, Item item) {
35 return item.getAcceptedCommandTypes().contains(PercentType.class);
39 public void perform(AbstractDevice device, Item item, String value) {
40 ItemCommandEvent event = ItemEventFactory.createCommandEvent(item.getName(), new PercentType(value),
42 eventPublisher.post(event);