Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[visualcrossing] Initial contribution #17239

Merged
merged 47 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e14553d
EVERYTHING
magx2 Aug 11, 2024
63ba0b8
i8n + format
magx2 Aug 11, 2024
3c6c411
proper channles
magx2 Aug 11, 2024
3523eea
return undefs
magx2 Aug 11, 2024
f78509f
proper solar energy unit
magx2 Aug 11, 2024
f3982d2
more code
magx2 Aug 11, 2024
7b5533a
i8n
magx2 Aug 12, 2024
6a62d0a
add visualcrossing to addons
magx2 Aug 12, 2024
1aa0278
add visualcrossing to addons
magx2 Aug 12, 2024
2708d70
channels
magx2 Aug 13, 2024
3b6e500
locale/location
magx2 Aug 13, 2024
866d4c3
locale/location
magx2 Aug 13, 2024
392fa94
allow to pick languages from list
magx2 Aug 19, 2024
c3ed92e
readme
magx2 Aug 22, 2024
f40d8ed
Update bundles/org.openhab.binding.visualcrossing/README.md
magx2 Aug 22, 2024
51e1ee7
Update bundles/org.openhab.binding.visualcrossing/src/main/java/org/o…
magx2 Aug 22, 2024
b46f729
Update bundles/org.openhab.binding.visualcrossing/src/main/resources/…
magx2 Aug 22, 2024
c9ced42
remarks
magx2 Aug 22, 2024
c665632
current-conditions
magx2 Aug 22, 2024
8044381
Update bundles/org.openhab.binding.visualcrossing/README.md
magx2 Aug 22, 2024
9eb3baa
channel groups
magx2 Aug 22, 2024
cf0a58a
Update bundles/org.openhab.binding.visualcrossing/src/main/resources/…
magx2 Aug 23, 2024
49a83ec
Update bundles/org.openhab.binding.visualcrossing/src/main/java/org/o…
magx2 Aug 23, 2024
885a871
Update bundles/org.openhab.binding.visualcrossing/src/main/resources/…
magx2 Aug 23, 2024
89e2ba1
review
magx2 Aug 23, 2024
dd0b7ea
review
magx2 Aug 23, 2024
af8c936
format table
magx2 Aug 23, 2024
5232732
format table
magx2 Aug 23, 2024
e4473e4
Use date time for times
magx2 Aug 25, 2024
521850e
Use raw `temperature-channel` instead of `system.outdoor-temperature`
magx2 Aug 25, 2024
cd0e0e7
Remove `*-epoch` for sunrise and sunset
magx2 Aug 25, 2024
ebc7eb8
add channel metadata
magx2 Aug 25, 2024
684dfe7
Update bundles/org.openhab.binding.visualcrossing/src/main/java/org/o…
magx2 Aug 25, 2024
ae41779
better overview
magx2 Aug 25, 2024
5c10087
format
magx2 Aug 25, 2024
099d8a3
revert
magx2 Aug 25, 2024
9dd23fc
Revert "Remove `*-epoch` for sunrise and sunset"
magx2 Aug 25, 2024
8e10ae1
proer handle of date time
magx2 Aug 25, 2024
b1395f8
proper counting of humidity
magx2 Aug 25, 2024
5f9dc2f
configure channels
magx2 Aug 26, 2024
a7334a8
add example configuration
magx2 Aug 26, 2024
d6047f4
remarks
magx2 Aug 27, 2024
19b7497
remarks
magx2 Aug 27, 2024
ce99f44
remarks
magx2 Aug 27, 2024
1a02b95
rewrite description
magx2 Aug 27, 2024
fb9f495
remove `full_example.items`
magx2 Aug 28, 2024
e5e132c
properties
magx2 Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
/bundles/org.openhab.binding.verisure/ @jannegpriv
/bundles/org.openhab.binding.vesync/ @dag81
/bundles/org.openhab.binding.vigicrues/ @clinique
/bundles/org.openhab.binding.visualcrossing/ @magx2
/bundles/org.openhab.binding.vitotronic/ @steand
/bundles/org.openhab.binding.vizio/ @mlobstein
/bundles/org.openhab.binding.volvooncall/ @Jamstah
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,11 @@
<artifactId>org.openhab.binding.vigicrues</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.visualcrossing</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.vitotronic</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.visualcrossing/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab-addons
359 changes: 359 additions & 0 deletions bundles/org.openhab.binding.visualcrossing/README.md

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions bundles/org.openhab.binding.visualcrossing/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>4.3.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.visualcrossing</artifactId>

<name>openHAB Add-ons :: Bundles :: VisualCrossing Binding</name>

<dependencies>
<!-- TEST -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.visualcrossing-${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-visualcrossing" description="VisualCrossing Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.visualcrossing/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/**
* Copyright (c) 2010-2024 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.visualcrossing.internal;

import static javax.measure.MetricPrefix.MEGA;
import static org.openhab.core.library.unit.MetricPrefix.*;
import static org.openhab.core.library.unit.SIUnits.*;
import static org.openhab.core.library.unit.Units.*;
import static org.openhab.core.types.UnDefType.UNDEF;

import java.util.Collection;
import java.util.function.Function;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.types.State;

/**
* @author Martin Grześlowski - Initial contribution
*/
@NonNullByDefault
class TypeBuilder {
private static State newStringType(@Nullable String string) {
return string != null ? new StringType(string) : UNDEF;
}

public static <T> State newStringType(@Nullable T obj, Function<T, @Nullable String> function) {
if (obj == null) {
return UNDEF;
}
return newStringType(function.apply(obj));
}

private static State newStringType(@Nullable Collection<String> strings) {
return strings != null ? new StringType(String.join(",", strings)) : UNDEF;
}

public static <T> State newStringCollectionType(@Nullable T obj,
Function<T, @Nullable Collection<String>> function) {
if (obj == null) {
return UNDEF;
}
return newStringType(function.apply(obj));
}

private static State newDecimalType(@Nullable Number number) {
return number != null ? new DecimalType(number) : UNDEF;
}

public static <T> State newDecimalType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newDecimalType(function.apply(obj));
}

private static State newTemperatureType(@Nullable Number temp) {
return temp != null ? new QuantityType<>(temp, CELSIUS) : UNDEF;
}

public static <T> State newTemperatureType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newTemperatureType(function.apply(obj));
}

private static State newHumidityType(@Nullable Number humidity) {
return humidity != null ? new DecimalType(humidity) : UNDEF;
}

public static <T> State newHumidityType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newHumidityType(function.apply(obj));
}

private static State newMilliLengthType(@Nullable Number length) {
return length != null ? new QuantityType<>(length, MILLI(METRE)) : UNDEF;
}

public static <T> State newMilliLengthType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newMilliLengthType(function.apply(obj));
}

private static State newCentiLengthType(@Nullable Number length) {
return length != null ? new QuantityType<>(length, CENTI(METRE)) : UNDEF;
}

public static <T> State newCentiLengthType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newCentiLengthType(function.apply(obj));
}

private static State newSpeedType(@Nullable Number speed) {
return speed != null ? new QuantityType<>(speed, KILOMETRE_PER_HOUR) : UNDEF;
}

public static <T> State newSpeedType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newSpeedType(function.apply(obj));
}

private static State newAngleType(@Nullable Number angle) {
return angle != null ? new QuantityType<>(angle, DEGREE_ANGLE) : UNDEF;
}

public static <T> State newAngleType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newAngleType(function.apply(obj));
}

private static State newMilliPressureType(@Nullable Number pressure) {
return pressure != null ? new QuantityType<>(pressure, MILLI(BAR)) : UNDEF;
}

public static <T> State newMilliPressureType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newMilliPressureType(function.apply(obj));
}

private static State newKiloMeterType(@Nullable Number km) {
return km != null ? new QuantityType<>(km, KILO(METRE)) : UNDEF;
}

public static <T> State newKiloMeterType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newKiloMeterType(function.apply(obj));
}

private static State newSolarRadiationType(@Nullable Number solarRadiation) {
return solarRadiation != null ? new QuantityType<>(solarRadiation, WATT.divide(METRE.multiply(METRE))) : UNDEF;
}

public static <T> State newSolarRadiationType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newSolarRadiationType(function.apply(obj));
}

private static State newSolarEnergyType(@Nullable Number solarEnergy) {
return solarEnergy != null ? new QuantityType<>(solarEnergy, MEGA(JOULE).divide(METRE.multiply(METRE))) : UNDEF;
}

public static <T> State newSolarEnergyType(@Nullable T obj, Function<T, @Nullable Number> function) {
if (obj == null) {
return UNDEF;
}
return newSolarEnergyType(function.apply(obj));
}
}
Loading