2 * Copyright (c) 2010-2024 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.openhabcloud.internal.actions;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.automation.Action;
20 import org.openhab.core.automation.handler.ModuleHandler;
21 import org.openhab.io.openhabcloud.internal.CloudService;
24 * This is a {@link ModuleHandler} implementation for {@link Action}s to send a notification to a specific cloud user.
26 * @author Christoph Weitkamp - Initial contribution
29 public class SendNotificationActionHandler extends BaseNotificationActionHandler {
31 public static final String TYPE_ID = "notification.SendNotification";
32 public static final String EXTENDED_TYPE_ID = "notification.SendExtendedNotification";
33 public static final String PARAM_USER = "userId";
35 private final String userId;
37 public SendNotificationActionHandler(Action module, CloudService cloudService) {
38 super(module, cloudService);
40 Object userIdParam = module.getConfiguration().get(PARAM_USER);
41 if (userIdParam instanceof String) {
42 this.userId = userIdParam.toString();
44 throw new IllegalArgumentException(String.format("Param '%s' should be of type String.", PARAM_USER));
49 public @Nullable Map<String, Object> execute(Map<String, Object> context) {
50 cloudService.sendNotification(userId, message, icon, severity);