added migrated 2.x add-ons

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer
2020-09-21 01:58:32 +02:00
parent bbf1a7fd29
commit 6df6783b60
11662 changed files with 1302875 additions and 11 deletions

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.pushbullet-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
<feature name="openhab-binding-pushbullet" description="Pushbullet Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.pushbullet/${project.version}</bundle>
</feature>
</features>

View File

@@ -0,0 +1,46 @@
/**
* Copyright (c) 2010-2020 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.pushbullet.internal;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;
/**
* The {@link PushbulletBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Hakan Tandogan - Initial contribution
*/
@NonNullByDefault
public class PushbulletBindingConstants {
private static final String BINDING_ID = "pushbullet";
// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_BOT = new ThingTypeUID(BINDING_ID, "bot");
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_BOT);
// List of all Channel ids
public static final String RECIPIENT = "recipient";
public static final String TITLE = "title";
public static final String MESSAGE = "message";
// Binding logic constants
public static final String API_METHOD_PUSHES = "pushes";
public static final int TIMEOUT = 30 * 1000; // 30 seconds
}

View File

@@ -0,0 +1,55 @@
/**
* Copyright (c) 2010-2020 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.pushbullet.internal;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
/**
* The {@link PushbulletConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Hakan Tandogan - Initial contribution
*/
@NonNullByDefault
public class PushbulletConfiguration {
private @Nullable String name;
private String token = "invalid";
private String apiUrlBase = "invalid";
public @Nullable String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getApiUrlBase() {
return apiUrlBase;
}
public void setApiUrlBase(String apiUrlBase) {
this.apiUrlBase = apiUrlBase;
}
}

View File

@@ -0,0 +1,52 @@
/**
* Copyright (c) 2010-2020 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.pushbullet.internal;
import static org.openhab.binding.pushbullet.internal.PushbulletBindingConstants.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.pushbullet.internal.handler.PushbulletHandler;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
import org.osgi.service.component.annotations.Component;
/**
* The {@link PushbulletHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Hakan Tandogan - Initial contribution
*/
@NonNullByDefault
@Component(configurationPid = "binding.pushbullet", service = ThingHandlerFactory.class)
public class PushbulletHandlerFactory extends BaseThingHandlerFactory {
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (THING_TYPE_BOT.equals(thingTypeUID)) {
return new PushbulletHandler(thing);
}
return null;
}
}

View File

@@ -0,0 +1,29 @@
/**
* Copyright (c) 2010-2020 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.pushbullet.internal.action;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
/**
* The {@link IPushbulletActions} interface defines rule actions for sending notifications
*
* @author Laurent Garnier - Initial contribution
*/
@NonNullByDefault
public interface IPushbulletActions {
public Boolean sendPushbulletNote(@Nullable String recipient, @Nullable String title, @Nullable String message);
public Boolean sendPushbulletNote(@Nullable String recipient, @Nullable String message);
}

View File

@@ -0,0 +1,123 @@
/**
* Copyright (c) 2010-2020 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.pushbullet.internal.action;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.pushbullet.internal.handler.PushbulletHandler;
import org.openhab.core.automation.annotation.ActionInput;
import org.openhab.core.automation.annotation.ActionOutput;
import org.openhab.core.automation.annotation.RuleAction;
import org.openhab.core.thing.binding.ThingActions;
import org.openhab.core.thing.binding.ThingActionsScope;
import org.openhab.core.thing.binding.ThingHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link PushbulletActions} class defines rule actions for sending notifications
* <p>
* <b>Note:</b>The static method <b>invokeMethodOf</b> handles the case where
* the test <i>actions instanceof PushbulletActions</i> fails. This test can fail
* due to an issue in openHAB core v2.5.0 where the {@link PushbulletActions} class
* can be loaded by a different classloader than the <i>actions</i> instance.
*
* @author Hakan Tandogan - Initial contribution
*/
@ThingActionsScope(name = "pushbullet")
@NonNullByDefault
public class PushbulletActions implements ThingActions, IPushbulletActions {
private final Logger logger = LoggerFactory.getLogger(PushbulletActions.class);
private @Nullable PushbulletHandler handler;
@Override
public void setThingHandler(@Nullable ThingHandler handler) {
this.handler = (PushbulletHandler) handler;
}
@Override
public @Nullable ThingHandler getThingHandler() {
return this.handler;
}
@Override
@RuleAction(label = "@text/actionSendPushbulletNoteLabel", description = "@text/actionSendPushbulletNoteDesc")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendPushbulletNote(
@ActionInput(name = "recipient", label = "@text/actionSendPushbulletNoteInputRecipientLabel", description = "@text/actionSendPushbulletNoteInputRecipientDesc") @Nullable String recipient,
@ActionInput(name = "title", label = "@text/actionSendPushbulletNoteInputTitleLabel", description = "@text/actionSendPushbulletNoteInputTitleDesc") @Nullable String title,
@ActionInput(name = "message", label = "@text/actionSendPushbulletNoteInputMessageLabel", description = "@text/actionSendPushbulletNoteInputMessageDesc") @Nullable String message) {
logger.trace("sendPushbulletNote '{}', '{}', '{}'", recipient, title, message);
// Use local variable so the SAT check can do proper flow analysis
PushbulletHandler localHandler = handler;
if (localHandler == null) {
logger.warn("Pushbullet service Handler is null!");
return false;
}
return localHandler.sendPush(recipient, title, message, "note");
}
public static boolean sendPushbulletNote(@Nullable ThingActions actions, @Nullable String recipient,
@Nullable String title, @Nullable String message) {
return invokeMethodOf(actions).sendPushbulletNote(recipient, title, message);
}
@Override
@RuleAction(label = "@text/actionSendPushbulletNoteLabel", description = "@text/actionSendPushbulletNoteDesc")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendPushbulletNote(
@ActionInput(name = "recipient", label = "@text/actionSendPushbulletNoteInputRecipientLabel", description = "@text/actionSendPushbulletNoteInputRecipientDesc") @Nullable String recipient,
@ActionInput(name = "message", label = "@text/actionSendPushbulletNoteInputMessageLabel", description = "@text/actionSendPushbulletNoteInputMessageDesc") @Nullable String message) {
logger.trace("sendPushbulletNote '{}', '{}'", recipient, message);
// Use local variable so the SAT check can do proper flow analysis
PushbulletHandler localHandler = handler;
if (localHandler == null) {
logger.warn("Pushbullet service Handler is null!");
return false;
}
return localHandler.sendPush(recipient, message, "note");
}
public static boolean sendPushbulletNote(@Nullable ThingActions actions, @Nullable String recipient,
@Nullable String message) {
return invokeMethodOf(actions).sendPushbulletNote(recipient, message);
}
private static IPushbulletActions invokeMethodOf(@Nullable ThingActions actions) {
if (actions == null) {
throw new IllegalArgumentException("actions cannot be null");
}
if (actions.getClass().getName().equals(PushbulletActions.class.getName())) {
if (actions instanceof IPushbulletActions) {
return (IPushbulletActions) actions;
} else {
return (IPushbulletActions) Proxy.newProxyInstance(IPushbulletActions.class.getClassLoader(),
new Class[] { IPushbulletActions.class }, (Object proxy, Method method, Object[] args) -> {
Method m = actions.getClass().getDeclaredMethod(method.getName(),
method.getParameterTypes());
return m.invoke(actions, args);
});
}
}
throw new IllegalArgumentException("Actions is not an instance of PushbulletActions");
}
}

View File

@@ -0,0 +1,229 @@
/**
* Copyright (c) 2010-2020 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.pushbullet.internal.handler;
import static org.openhab.binding.pushbullet.internal.PushbulletBindingConstants.*;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.MimeTypes;
import org.openhab.binding.pushbullet.internal.PushbulletConfiguration;
import org.openhab.binding.pushbullet.internal.action.PushbulletActions;
import org.openhab.binding.pushbullet.internal.model.Push;
import org.openhab.binding.pushbullet.internal.model.PushResponse;
import org.openhab.core.io.net.http.HttpUtil;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.thing.binding.ThingHandlerService;
import org.openhab.core.types.Command;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
* The {@link PushbulletHandler} is responsible for handling commands, which are
* sent to one of the channels.
*
* @author Hakan Tandogan - Initial contribution
*/
@NonNullByDefault
public class PushbulletHandler extends BaseThingHandler {
private final Logger logger = LoggerFactory.getLogger(PushbulletHandler.class);
private final Gson gson = new GsonBuilder().create();
private static final Version VERSION = FrameworkUtil.getBundle(PushbulletHandler.class).getVersion();
private static final Pattern CHANNEL_PATTERN = Pattern.compile("^[a-zA-Z0-9_-]+$");
private @Nullable PushbulletConfiguration config;
public PushbulletHandler(Thing thing) {
super(thing);
}
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("About to handle {} on {}", command, channelUID);
// Future improvement: If recipient is already set, send a push on a command channel change
// check reconnect channel of the unifi binding for that
logger.debug("The Pushbullet binding is a read-only binding and cannot handle command '{}'.", command);
}
@Override
public void initialize() {
logger.debug("Start initializing!");
config = getConfigAs(PushbulletConfiguration.class);
// Name and Token are both "required", so set the Thing immediately ONLINE.
updateStatus(ThingStatus.ONLINE);
logger.debug("Finished initializing!");
}
@Override
public Collection<Class<? extends ThingHandlerService>> getServices() {
return Collections.singleton(PushbulletActions.class);
}
public boolean sendPush(@Nullable String recipient, @Nullable String message, String type) {
return sendPush(recipient, "", message, type);
}
public boolean sendPush(@Nullable String recipient, @Nullable String title, @Nullable String message, String type) {
boolean result = false;
logger.debug("sendPush is called for ");
logger.debug("Thing {}", thing);
logger.debug("Thing Label: '{}'", thing.getLabel());
PushbulletConfiguration configuration = getConfigAs(PushbulletConfiguration.class);
logger.debug("CFG {}", configuration);
Properties headers = prepareRequestHeaders(configuration);
String request = prepareMessageBody(recipient, title, message, type);
try (InputStream stream = new ByteArrayInputStream(request.getBytes(StandardCharsets.UTF_8))) {
String pushAPI = configuration.getApiUrlBase() + "/" + API_METHOD_PUSHES;
String responseString = HttpUtil.executeUrl(HttpMethod.POST.asString(), pushAPI, headers, stream,
MimeTypes.Type.APPLICATION_JSON.asString(), TIMEOUT);
logger.debug("Got Response: {}", responseString);
PushResponse response = gson.fromJson(responseString, PushResponse.class);
logger.debug("Unpacked Response: {}", response);
stream.close();
if ((null != response) && (null == response.getPushError())) {
result = true;
}
} catch (IOException e) {
logger.warn("IO problems pushing note: {}", e.getMessage());
}
return result;
}
/**
* helper method to populate the request headers
*
* @param configuration
* @return
*/
private Properties prepareRequestHeaders(PushbulletConfiguration configuration) {
Properties headers = new Properties();
headers.put(HttpHeader.USER_AGENT, "openHAB / Pushbullet binding " + VERSION);
headers.put(HttpHeader.CONTENT_TYPE, MimeTypes.Type.APPLICATION_JSON.asString());
headers.put("Access-Token", configuration.getToken());
logger.debug("Headers: {}", headers);
return headers;
}
/**
* helper method to create a message body from data to be transferred.
*
* @param recipient
* @param title
* @param message
* @param type
*
* @return the message as a String to be posted
*/
private String prepareMessageBody(@Nullable String recipient, @Nullable String title, @Nullable String message,
String type) {
logger.debug("Recipient is '{}'", recipient);
logger.debug("Title is '{}'", title);
logger.debug("Message is '{}'", message);
Push push = new Push();
push.setTitle(title);
push.setBody(message);
push.setType(type);
if (recipient != null) {
if (isValidEmail(recipient)) {
logger.debug("Recipient is an email address");
push.setEmail(recipient);
} else if (isValidChannel(recipient)) {
logger.debug("Recipient is a channel tag");
push.setChannel(recipient);
} else {
logger.warn("Invalid recipient: {}", recipient);
logger.warn("Message will be broadcast to all user's devices.");
}
}
logger.debug("Push: {}", push);
String request = gson.toJson(push);
logger.debug("Packed Request: {}", request);
return request;
}
/**
* helper method checking if channel tag is valid.
*
* @param channel
* @return
*/
private static boolean isValidChannel(String channel) {
Matcher m = CHANNEL_PATTERN.matcher(channel);
return m.matches();
}
/**
* helper method checking if email address is valid.
*
* @param email
* @return
*/
private static boolean isValidEmail(String email) {
try {
InternetAddress emailAddr = new InternetAddress(email);
emailAddr.validate();
return true;
} catch (AddressException e) {
return false;
}
}
}

View File

@@ -0,0 +1,85 @@
/**
* Copyright (c) 2010-2020 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.pushbullet.internal.model;
import com.google.gson.annotations.SerializedName;
/**
* This class represents the push request sent to the API.
*
* @author Hakan Tandogan - Initial contribution
* @author Hakan Tandogan - Migrated from openHAB 1 action with the same name
*/
public class Push {
@SerializedName("title")
private String title;
@SerializedName("body")
private String body;
@SerializedName("type")
private String type;
@SerializedName("email")
private String email;
@SerializedName("channel_tag")
private String channelTag;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getChannel() {
return channelTag;
}
public void setChannel(String channelTag) {
this.channelTag = channelTag;
}
@Override
public String toString() {
return "Push {" + "title='" + title + '\'' + ", body='" + body + '\'' + ", type='" + type + '\'' + ", email='"
+ email + '\'' + ", channelTag='" + channelTag + '\'' + '}';
}
}

View File

@@ -0,0 +1,74 @@
/**
* Copyright (c) 2010-2020 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.pushbullet.internal.model;
import com.google.gson.annotations.SerializedName;
/**
* This class represents errors in the response fetched from the API.
*
* @author Hakan Tandogan - Initial contribution
* @author Hakan Tandogan - Migrated from openHAB 1 action with the same name
*/
public class PushError {
@SerializedName("type")
private String type;
@SerializedName("message")
private String message;
@SerializedName("param")
private String param;
@SerializedName("cat")
private String cat;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getParam() {
return param;
}
public void setParam(String param) {
this.param = param;
}
public String getCat() {
return cat;
}
public void setCat(String cat) {
this.cat = cat;
}
@Override
public String toString() {
return "PushError {" + "type='" + type + '\'' + ", message='" + message + '\'' + ", param='" + param + '\''
+ ", cat='" + cat + '\'' + '}';
}
}

View File

@@ -0,0 +1,211 @@
/**
* Copyright (c) 2010-2020 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.pushbullet.internal.model;
import com.google.gson.annotations.SerializedName;
/**
* This class represents the answer to pushes provided by the API.
*
* @author Hakan Tandogan - Initial contribution
* @author Hakan Tandogan - Migrated from openHAB 1 action with the same name
*/
public class PushResponse {
@SerializedName("active")
private String active;
@SerializedName("iden")
private String iden;
@SerializedName("type")
private String type;
@SerializedName("dismissed")
private Boolean dismissed;
@SerializedName("direction")
private String direction;
@SerializedName("sender_iden")
private String senderIdentifier;
@SerializedName("sender_email")
private String senderEmail;
@SerializedName("sender_email_normalized")
private String senderEmailNormalized;
@SerializedName("sender_name")
private String senderName;
@SerializedName("receiver_iden")
private String receiverIdentifier;
@SerializedName("receiver_email")
private String receiverEmail;
@SerializedName("receiver_email_normalized")
private String receiverEmailNormalized;
@SerializedName("title")
private String title;
@SerializedName("body")
private String body;
@SerializedName("error_code")
private String errorCode;
@SerializedName("error")
private PushError pushError;
public String getActive() {
return active;
}
public void setActive(String active) {
this.active = active;
}
public String getIden() {
return iden;
}
public void setIden(String iden) {
this.iden = iden;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Boolean getDismissed() {
return dismissed;
}
public void setDismissed(Boolean dismissed) {
this.dismissed = dismissed;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public String getSenderIdentifier() {
return senderIdentifier;
}
public void setSenderIdentifier(String senderIdentifier) {
this.senderIdentifier = senderIdentifier;
}
public String getSenderEmail() {
return senderEmail;
}
public void setSenderEmail(String senderEmail) {
this.senderEmail = senderEmail;
}
public String getSenderEmailNormalized() {
return senderEmailNormalized;
}
public void setSenderEmailNormalized(String senderEmailNormalized) {
this.senderEmailNormalized = senderEmailNormalized;
}
public String getSenderName() {
return senderName;
}
public void setSenderName(String senderName) {
this.senderName = senderName;
}
public String getReceiverIdentifier() {
return receiverIdentifier;
}
public void setReceiverIdentifier(String receiverIdentifier) {
this.receiverIdentifier = receiverIdentifier;
}
public String getReceiverEmail() {
return receiverEmail;
}
public void setReceiverEmail(String receiverEmail) {
this.receiverEmail = receiverEmail;
}
public String getReceiverEmailNormalized() {
return receiverEmailNormalized;
}
public void setReceiverEmailNormalized(String receiverEmailNormalized) {
this.receiverEmailNormalized = receiverEmailNormalized;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public PushError getPushError() {
return pushError;
}
public void setPushError(PushError pushError) {
this.pushError = pushError;
}
@Override
public String toString() {
return "PushResponse {" + "active='" + active + '\'' + ", iden='" + iden + '\'' + ", type='" + type + '\''
+ ", dismissed=" + dismissed + ", direction='" + direction + '\'' + ", senderIdentifier='"
+ senderIdentifier + '\'' + ", senderEmail='" + senderEmail + '\'' + ", senderEmailNormalized='"
+ senderEmailNormalized + '\'' + ", senderName='" + senderName + '\'' + ", receiverIdentifier='"
+ receiverIdentifier + '\'' + ", receiverEmail='" + receiverEmail + '\'' + ", receiverEmailNormalized='"
+ receiverEmailNormalized + '\'' + ", title='" + title + '\'' + ", body='" + body + '\''
+ ", errorCode='" + errorCode + '\'' + ", pushError=" + pushError + '}';
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="pushbullet" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">
<name>@text/binding.pushbullet.name</name>
<description>@text/binding.pushbullet.description</description>
<author>Hakan Tandoğan</author>
</binding:binding>

View File

@@ -0,0 +1,17 @@
# binding
binding.pushbullet.name = Pushbullet Binding
binding.pushbullet.description = The Pushbullet binding allows you to send messages to other users of the Pushbullet service.
# action
actionSendPushbulletNoteLabel = publish an Pushbullet message
actionSendPushbulletNoteDesc = Publishes a Title to the given Pushbullet Recipient.
actionSendPushbulletNoteInputRecipientLabel = Pushbullet Recipient
actionSendPushbulletNoteInputRecipientDesc = The Recipient to publish a Title to.
actionSendPushbulletNoteInputTitleLabel = Title
actionSendPushbulletNoteInputTitleDesc = The Title to publish
actionSendPushbulletNoteInputMessageLabel = Message
actionSendPushbulletNoteInputMessageDesc = The Message to publish
# error texts
offline.conf-error-httpresponseexception = The pushbullet server reported an error, possibly an expired token. Check on web site

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="pushbullet"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<thing-type id="bot">
<label>Pushbullet Bot</label>
<description>Bot to send messages with.</description>
<channels>
<channel id="recipient" typeId="recipient-channel"/>
<channel id="title" typeId="title-channel"/>
<channel id="message" typeId="message-channel"/>
</channels>
<config-description>
<parameter name="name" type="text" required="false">
<label>Name</label>
<description>Explicit Name of Bot, if wanted</description>
<advanced>true</advanced>
</parameter>
<parameter name="token" type="text" required="true">
<label>Token</label>
<description>Token as obtained from the server</description>
</parameter>
<parameter name="apiUrlBase" type="text" required="true">
<label>API Server</label>
<description>The Pushbullet API Server to use, for local testing</description>
<default>https://api.pushbullet.com/v2</default>
<advanced>true</advanced>
</parameter>
</config-description>
</thing-type>
<channel-type id="recipient-channel">
<item-type>String</item-type>
<label>Recipient</label>
<description>Mail address or Channel Name</description>
</channel-type>
<channel-type id="title-channel">
<item-type>String</item-type>
<label>Title</label>
<description>Title of the message</description>
</channel-type>
<channel-type id="message-channel">
<item-type>String</item-type>
<label>Message</label>
<description>The text that is to be sent</description>
</channel-type>
</thing:thing-descriptions>