Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #8 from openhab/master
Browse files Browse the repository at this point in the history
Update from openhab sources
  • Loading branch information
csowada committed Mar 30, 2015
2 parents f5d3ff5 + 7d4d763 commit 779df04
Show file tree
Hide file tree
Showing 845 changed files with 69,926 additions and 13,919 deletions.
8 changes: 8 additions & 0 deletions bundles/action/org.openhab.action.astro/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.core.drools</name>
<comment>This is the optional Drools rule engine of the open Home Automation Bus (openHAB)</comment>
<name>org.openhab.action.astro</name>
<comment>This is the ${binding-name} binding of the open Home Automation Bus (openHAB)</comment>
<projects>
</projects>
<buildSpec>
Expand Down
28 changes: 28 additions & 0 deletions bundles/action/org.openhab.action.astro/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Manifest-Version: 1.0
Private-Package: org.openhab.action.astro.internal
Ignore-Package: org.openhab.action.astro.internal
Bundle-License: http://www.eclipse.org/legal/epl-v10.html
Bundle-Name: openHAB Astro Action
Bundle-SymbolicName: org.openhab.action.astro
Bundle-Vendor: openHAB.org
Bundle-Version: 1.7.0.qualifier
Bundle-Activator: org.openhab.action.astro.internal.AstroActivator
Bundle-ManifestVersion: 2
Bundle-Description: This is the Astro action of the open Home Aut
omation Bus (openHAB)
Import-Package: org.apache.commons.lang.builder,
org.openhab.core.items,
org.openhab.core.library.items,
org.openhab.core.library.types,
org.openhab.core.scriptengine.action,
org.openhab.core.types,
org.osgi.framework,
org.osgi.service.cm,
org.osgi.service.component,
org.slf4j
Bundle-DocURL: http://www.openhab.org
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/action.xml
Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy
Require-Bundle: org.openhab.binding.astro
21 changes: 21 additions & 0 deletions bundles/action/org.openhab.action.astro/OSGI-INF/action.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010-2015, openHAB.org and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" immediate="true" name="org.openhab.action.astro.action">
<implementation class="org.openhab.action.astro.internal.AstroActionService" />

<service>
<provide interface="org.openhab.core.scriptengine.action.ActionService" />
</service>

<property name="service.pid" type="String" value="org.openhab.astro.action" />

</scr:component>
6 changes: 6 additions & 0 deletions bundles/action/org.openhab.action.astro/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source.. = src/main/java/,\
src/main/resources/
bin.includes = META-INF/,\
.,\
OSGI-INF/
output.. = target/classes/
35 changes: 35 additions & 0 deletions bundles/action/org.openhab.action.astro/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
<groupId>org.openhab.bundles</groupId>
<artifactId>action</artifactId>
<version>1.7.0-SNAPSHOT</version>
</parent>

<properties>
<bundle.symbolicName>org.openhab.action.astro</bundle.symbolicName>
<bundle.namespace>org.openhab.action.astro</bundle.namespace>
<deb.name>openhab-addon-action-astro</deb.name>
<deb.description>openhab addon action astro</deb.description>
</properties>

<modelVersion>4.0.0</modelVersion>
<groupId>org.openhab.action</groupId>
<artifactId>org.openhab.action.astro</artifactId>

<name>openHAB Astro Action</name>

<packaging>eclipse-plugin</packaging>

<build>
<plugins>
<plugin>
<groupId>org.vafer</groupId>
<artifactId>jdeb</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Copyright (c) 2010-2015, openHAB.org and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.action.astro.internal;

import java.util.Calendar;
import java.util.Date;

import org.openhab.binding.astro.internal.calc.SunCalc;
import org.openhab.binding.astro.internal.model.Sun;
import org.openhab.core.scriptengine.action.ActionDoc;
import org.openhab.core.scriptengine.action.ParamDoc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This class provides static methods that can be used in automation rules for
* calculating astronomical data.
*
* @author Gerhard Riegler
* @since 1.7.0
*/
public class Astro {
private static final Logger logger = LoggerFactory.getLogger(Astro.class);

private static final SunCalc sunCalc = new SunCalc();
// simple microcache
private static AstroConfig lastConfig;
private static Sun lastSun;

@ActionDoc(text = "Returns the sunrise start for the given date and coordinates")
public static Calendar getAstroSunriseStart(
@ParamDoc(name = "date", text = "The date to calculate the sunrise") Date date,
@ParamDoc(name = "latitude", text = "The latitude") double latitude,
@ParamDoc(name = "longitude", text = "The longitude") double longitude) {
return getSun(date, latitude, longitude).getRise().getStart();
}

@ActionDoc(text = "Returns the sunrise end for the given date and coordinates")
public static Calendar getAstroSunriseEnd(
@ParamDoc(name = "date", text = "The date to calculate the sunrise") Date date,
@ParamDoc(name = "latitude", text = "The latitude") double latitude,
@ParamDoc(name = "longitude", text = "The longitude") double longitude) {
return getSun(date, latitude, longitude).getRise().getEnd();
}

@ActionDoc(text = "Returns the sunset start for the given date and coordinates")
public static Calendar getAstroSunsetStart(
@ParamDoc(name = "date", text = "The date to calculate the sunset") Date date,
@ParamDoc(name = "latitude", text = "The latitude") double latitude,
@ParamDoc(name = "longitude", text = "The longitude") double longitude) {
return getSun(date, latitude, longitude).getSet().getStart();
}

@ActionDoc(text = "Returns the sunset end for the given date and coordinates")
public static Calendar getAstroSunsetEnd(
@ParamDoc(name = "date", text = "The date to calculate the sunset") Date date,
@ParamDoc(name = "latitude", text = "The latitude") double latitude,
@ParamDoc(name = "longitude", text = "The longitude") double longitude) {
return getSun(date, latitude, longitude).getSet().getEnd();
}

/**
* Calculates the sun data.
*/
private static Sun getSun(Date date, double latitude, double longitude) {
if (date == null) {
logger.warn("Unknown date: {}, using current date", date);
date = new Date();
}
AstroConfig config = new AstroConfig(date, latitude, longitude);
if (lastConfig == null || !lastConfig.equals(config)) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
lastSun = sunCalc.getSunInfo(cal, latitude, longitude);
lastConfig = config;
}
return lastSun;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright (c) 2010-2015, openHAB.org and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.action.astro.internal;

import org.openhab.core.scriptengine.action.ActionService;

/**
* This class registers an OSGi service for the Astro action.
*
* @author Gerhard Riegler
* @since 1.7.0
*/
public class AstroActionService implements ActionService {

public void activate() {
}

public void deactivate() {
}

/**
* {@inheritDoc}
*/
@Override
public String getActionClassName() {
return Astro.class.getCanonicalName();
}

/**
* {@inheritDoc}
*/
@Override
public Class<?> getActionClass() {
return Astro.class;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (c) 2010-2015, openHAB.org and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.action.astro.internal;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Extension of the default OSGi bundle activator
*
* @author Gerhard Riegler
* @since 1.7.0
*/
public final class AstroActivator implements BundleActivator {
private static Logger logger = LoggerFactory.getLogger(AstroActivator.class);

private static BundleContext context;

/**
* Called whenever the OSGi framework starts our bundle
*/
public void start(BundleContext bc) throws Exception {
context = bc;
logger.debug("Astro action has been started.");
}

/**
* Called whenever the OSGi framework stops our bundle
*/
public void stop(BundleContext bc) throws Exception {
context = null;
logger.debug("Astro action has been stopped.");
}

/**
* Returns the bundle context of this bundle
*
* @return the bundle context
*/
public static BundleContext getContext() {
return context;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* Copyright (c) 2010-2015, openHAB.org and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.action.astro.internal;

import java.util.Date;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Holds the rule method parameters.
*
* @author Gerhard Riegler
* @since 1.7.0
*/
public class AstroConfig {
private Date date;
private double latitude;
private double longitude;

/**
* Creates a new AstroConfig.
*/
public AstroConfig(Date date, double latitude, double longitude) {
this.date = date;
this.latitude = latitude;
this.longitude = longitude;
}

/**
* Returns the date to calculate astro data.
*/
public Date getDate() {
return date;
}

/**
* The latitude to calculate astro data.
*/
public double getLatitude() {
return latitude;
}

/**
* The longitude to calculate astro data.
*/
public double getLongitude() {
return longitude;
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return new HashCodeBuilder().append(date).append(latitude).append(longitude).toHashCode();
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof AstroConfig)) {
return false;
}
AstroConfig config = (AstroConfig) obj;
return new EqualsBuilder().append(date, config.getDate()).append(latitude, config.getLatitude())
.append(longitude, config.getLongitude()).isEquals();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bundle resources go in here!
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ static public boolean sendMail(

try {
email.setFrom(from);
email.addTo(to);
String[] toList = to.split(";");
for (String toAddress : toList){
email.addTo(toAddress);
}
if(!StringUtils.isEmpty(subject)) email.setSubject(subject);
if(!StringUtils.isEmpty(message)) email.setMsg(message);
email.send();
Expand Down
8 changes: 8 additions & 0 deletions bundles/action/org.openhab.action.mios/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Loading

0 comments on commit 779df04

Please sign in to comment.