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

[solarforecast] Initial contribution #13308

Merged
merged 111 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
22615c6
initial commit
weymann Jul 19, 2022
130eab0
redesign forecast and location bugfix
weymann Jul 19, 2022
a07d739
bugfixes after testing
weymann Jul 21, 2022
b606862
add solcast service
weymann Jul 24, 2022
39556fe
solcast Bearer auth
weymann Jul 24, 2022
660ec9e
remove single plane handlers
weymann Jul 25, 2022
406ea19
readme updates
weymann Jul 26, 2022
c3b494d
alpha version for marketplace
weymann Jul 28, 2022
845d4a7
avoid zero reporting if forecast update fails
weymann Jul 28, 2022
8c5d344
minor readme changes
weymann Jul 28, 2022
db3e622
add solcast tuning measures
weymann Aug 1, 2022
11eb89a
timeframe measurements
weymann Aug 3, 2022
2649437
switch solcast service to ZonedDateTime with openHAB ZoneId
weymann Aug 4, 2022
ad2ec71
add actual-power channel
weymann Aug 5, 2022
23de30c
feature: add Actions
weymann Aug 6, 2022
b88cc59
trace adaptions
weymann Aug 7, 2022
f22133d
readme corrections
weymann Aug 7, 2022
9a26bd6
readme corrections
weymann Aug 7, 2022
9bbbce3
rework forecast solar with testing of corner cases
weymann Aug 8, 2022
e75fe7a
solcast bugfixes and test enhancement
weymann Aug 8, 2022
270c446
solcast actions providing optimistic and pessimistic values
weymann Aug 9, 2022
dacc484
change TimeZoneProvider handling
weymann Aug 9, 2022
da12ba9
bugfix actions arguments
weymann Aug 9, 2022
22b7591
readme corrections
weymann Aug 9, 2022
77e0659
readme corrections
weymann Aug 9, 2022
6b4619c
readme corrections
weymann Aug 9, 2022
4910332
interpolation optimization
weymann Aug 14, 2022
a131ab0
json dependency correction
weymann Aug 18, 2022
86ebe2b
unit corrections
weymann Aug 18, 2022
1bd9a81
remove unused imports
weymann Aug 18, 2022
967e84c
add bom dependency
weymann Aug 24, 2022
ef14a3d
Stability Forecast.Solar
weymann Sep 9, 2022
6f4e2fb
add damping feature
weymann Sep 16, 2022
5ec22ac
add horizon config
weymann Nov 2, 2022
ef8d94c
readme adjustment
weymann Nov 5, 2022
6c14255
spotless
weymann Nov 6, 2022
f9fd436
packages for config and handlers
weymann Jun 6, 2023
058ae60
updateStatuss using text keys
weymann Jun 6, 2023
7d10083
Using Instant for Internal time measurements
weymann Jun 7, 2023
c492ffb
checkstyle warnings solved
weymann Jun 7, 2023
23fd3f3
logging rework
weymann Jun 8, 2023
5a1c1ec
remove unused failure counter
weymann Jun 8, 2023
c54ef69
Using Instant for sendMeasure timings
weymann Jun 8, 2023
811357a
Add timeZone config for Solcast
weymann Jun 8, 2023
7e7b384
i18n for rule actions
weymann Jun 8, 2023
f2f0f1a
resolve compiler warnings
weymann Jun 8, 2023
0591e54
Switch to OH4
weymann Jun 8, 2023
fe2af4d
addon.xml
weymann Jun 8, 2023
8ee2f2b
bugfix horizon url
weymann Jun 11, 2023
a2e3592
update traget to OH4.1
weymann Jul 27, 2023
737cc30
update json version
weymann Jul 27, 2023
a0478f5
bugfix addon.xml
weymann Jul 31, 2023
a21388f
Forecast Solar internal zone handling
weymann Nov 15, 2023
f5c4576
bugfix: Solcast zone conversions
weymann Nov 15, 2023
3c4aa30
review comments corrections
weymann Nov 16, 2023
c86a311
review comments
weymann Nov 16, 2023
4e297a7
review comments
weymann Nov 16, 2023
73bf4b5
bugfix: zone calculation
weymann Nov 16, 2023
6cb8257
switch to ZonedDateTime
weymann Nov 17, 2023
ff345c7
Instant interface
weymann Nov 18, 2023
d0e6423
thing status bugfixes
weymann Nov 18, 2023
642b922
readme Instant adaptions
weymann Nov 18, 2023
eedc604
bugfix initial delay
weymann Nov 19, 2023
2f4b175
minor: initial delay has no effect - remove
weymann Nov 24, 2023
693fac6
readme typos
weymann Dec 7, 2023
d32bc8f
review comments
weymann Jan 8, 2024
071b98e
header year switch
weymann Jan 9, 2024
6974ea4
remove power feedback
weymann Jan 9, 2024
0e8921c
TimeSeries introduction
weymann Jan 9, 2024
d659adb
review comments
weymann Jan 9, 2024
81b0ab4
IllegalArguments introduced
weymann Jan 9, 2024
463ba86
fast update for RefreshType
weymann Jan 10, 2024
607a4f5
readme and naming adaptions
weymann Jan 10, 2024
a973f79
add up TimeSeries for Bridge
weymann Jan 16, 2024
80ecfba
add up TimeSeries for Bridge
weymann Jan 16, 2024
3358fc3
correct state pattern for Watt
weymann Jan 16, 2024
6851d40
split valid into valid and expired
weymann Jan 16, 2024
09220ed
use Duration instead of subtracting minutes
weymann Jan 16, 2024
7d8ab41
avoid unit test logging
weymann Jan 16, 2024
fe3a5e9
bugfix expiration calculation
weymann Feb 11, 2024
c1cec44
bugfix pessimistic optimisitc channels
weymann Feb 11, 2024
434c45a
bugfix optimistic pessimitic sc-site
weymann Feb 12, 2024
027dd39
Solcast channel rework
weymann Feb 18, 2024
15e465f
readme adaptions
weymann Feb 26, 2024
6d28f72
readme adaptions
weymann Feb 26, 2024
7f345f8
fix review comments
weymann Apr 4, 2024
abb77d9
fix review comments
weymann Apr 4, 2024
4dac423
Improve SolarForecast location config handling
weymann Apr 17, 2024
723b890
config updates
weymann Apr 17, 2024
646559a
config Optional handling
weymann Apr 17, 2024
6978890
first version exception handling
weymann Apr 21, 2024
7627528
first version exception handling
weymann Apr 21, 2024
472137c
switch case optimization
weymann Apr 21, 2024
fa20686
switched ForecastSolar to exception handling
weymann Apr 21, 2024
87c3ecf
Solcast exception handling
weymann Apr 21, 2024
10c2d37
fix checkstyle
weymann Apr 21, 2024
da56d39
readme adaptions
weymann Apr 22, 2024
278b735
bugfixing after testing
weymann Apr 22, 2024
9d0ef6f
bugfixing after testing
weymann Apr 22, 2024
7bb83b4
readme json channel correction
weymann Apr 22, 2024
75de2f1
bugfix: action call with average parameter
weymann Apr 26, 2024
8b8d940
adaptions from review comments
weymann Apr 26, 2024
a5bbe4b
remove instance check
weymann Apr 28, 2024
20c6452
remove unused logger
weymann Apr 28, 2024
9ec9aee
fix review comments
weymann Apr 28, 2024
e6f3253
bugfix persistence: common start and end time
weymann Apr 30, 2024
801b7bd
eliminated compiler warnings
weymann Apr 30, 2024
ed62e83
avoid warning messages in unit tests
weymann Apr 30, 2024
d2e9dfb
fix checkstyle
weymann Apr 30, 2024
2e17c8c
fix checkstyle
weymann Apr 30, 2024
ba3850b
fix review comments
weymann May 1, 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
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,11 @@
<artifactId>org.openhab.binding.solaredge</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.solarforecast</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.solarlog</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.solarforecast/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
356 changes: 356 additions & 0 deletions bundles/org.openhab.binding.solarforecast/README.md

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions bundles/org.openhab.binding.solarforecast/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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.2.0-SNAPSHOT</version>
</parent>

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

<name>openHAB Add-ons :: Bundles :: SolarForecast Binding</name>
<dependencies>
<!-- version needs to match with other projects like org.openhab.io.openhabcloud.pom.xml -->
weymann marked this conversation as resolved.
Show resolved Hide resolved
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20231013</version>
<scope>compile</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.solarforecast-${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-solarforecast" description="SolarForecast Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.solarforecast/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* 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.solarforecast.internal;

import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link SolarForecastBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Bernd Weymann - Initial contribution
*/
@NonNullByDefault
public class SolarForecastBindingConstants {

private static final String BINDING_ID = "solarforecast";

// Things
public static final ThingTypeUID FORECAST_SOLAR_SITE = new ThingTypeUID(BINDING_ID, "fs-site");
public static final ThingTypeUID FORECAST_SOLAR_PLANE = new ThingTypeUID(BINDING_ID, "fs-plane");
public static final ThingTypeUID SOLCAST_SITE = new ThingTypeUID(BINDING_ID, "sc-site");
public static final ThingTypeUID SOLCAST_PLANE = new ThingTypeUID(BINDING_ID, "sc-plane");
public static final Set<ThingTypeUID> SUPPORTED_THING_SET = Set.of(FORECAST_SOLAR_SITE, FORECAST_SOLAR_PLANE,
SOLCAST_SITE, SOLCAST_PLANE);

// Channel groups
public static final String GROUP_AVERAGE = "average";
public static final String GROUP_OPTIMISTIC = "optimistic";
public static final String GROUP_PESSIMISTIC = "pessimistic";
public static final String GROUP_RAW = "raw";

// Channels
public static final String CHANNEL_POWER_ESTIMATE = "power-estimate";
public static final String CHANNEL_ENERGY_ESTIMATE = "energy-estimate";
public static final String CHANNEL_POWER_ACTUAL = "power-actual";
public static final String CHANNEL_ENERGY_ACTUAL = "energy-actual";
public static final String CHANNEL_ENERGY_REMAIN = "energy-remain";
public static final String CHANNEL_ENERGY_TODAY = "energy-today";
public static final String CHANNEL_JSON = "json";

// Other
public static final int REFRESH_ACTUAL_INTERVAL = 1;
public static final String SLASH = "/";
public static final String EMPTY = "";
public static final String PATTERN_FORMAT = "yyyy-MM-dd HH:mm:ss";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* 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.solarforecast.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.solarforecast.internal.actions.SolarForecast;

/**
* The {@link SolarForecastException} is thrown if forecast data is invalid
*
* @author Bernd Weymann - Initial contribution
*/
@NonNullByDefault
@SuppressWarnings("serial")
public class SolarForecastException extends RuntimeException {

public SolarForecastException(SolarForecast ref, String message) {
super(ref.getIdentifier() + " # " + message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* 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.solarforecast.internal;

import static org.openhab.binding.solarforecast.internal.SolarForecastBindingConstants.*;

import java.util.Optional;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.solarforecast.internal.forecastsolar.handler.ForecastSolarBridgeHandler;
import org.openhab.binding.solarforecast.internal.forecastsolar.handler.ForecastSolarPlaneHandler;
import org.openhab.binding.solarforecast.internal.solcast.handler.SolcastBridgeHandler;
import org.openhab.binding.solarforecast.internal.solcast.handler.SolcastPlaneHandler;
import org.openhab.core.i18n.LocationProvider;
import org.openhab.core.i18n.TimeZoneProvider;
import org.openhab.core.io.net.http.HttpClientFactory;
import org.openhab.core.library.types.PointType;
import org.openhab.core.thing.Bridge;
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.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link SolarForecastHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Bernd Weymann - Initial contribution
*/
@NonNullByDefault
@Component(configurationPid = "binding.solarforecast", service = ThingHandlerFactory.class)
public class SolarForecastHandlerFactory extends BaseThingHandlerFactory {
private final TimeZoneProvider timeZoneProvider;
private final HttpClient httpClient;
private Optional<PointType> location = Optional.empty();

@Activate
public SolarForecastHandlerFactory(final @Reference HttpClientFactory hcf, final @Reference LocationProvider lp,
final @Reference TimeZoneProvider tzp) {
timeZoneProvider = tzp;
httpClient = hcf.getCommonHttpClient();
PointType pt = lp.getLocation();
if (pt != null) {
location = Optional.of(pt);
}
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SolarForecastBindingConstants.SUPPORTED_THING_SET.contains(thingTypeUID);
}

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (FORECAST_SOLAR_SITE.equals(thingTypeUID)) {
return new ForecastSolarBridgeHandler((Bridge) thing, location);
} else if (FORECAST_SOLAR_PLANE.equals(thingTypeUID)) {
return new ForecastSolarPlaneHandler(thing, httpClient);
} else if (SOLCAST_SITE.equals(thingTypeUID)) {
return new SolcastBridgeHandler((Bridge) thing, timeZoneProvider);
} else if (SOLCAST_PLANE.equals(thingTypeUID)) {
return new SolcastPlaneHandler(thing, httpClient);
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/**
* 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.solarforecast.internal.actions;

import java.time.Instant;
import java.time.LocalDate;

import javax.measure.quantity.Energy;
import javax.measure.quantity.Power;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.solarforecast.internal.solcast.SolcastObject.QueryMode;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.types.TimeSeries;

/**
* The {@link SolarForecast} Interface needed for Actions
*
* @author Bernd Weymann - Initial contribution
*/
@NonNullByDefault
public interface SolarForecast {
/**
* Argument can be used to query an average forecast scenario
*/
public static final String AVERAGE = "average";
/**
* Argument can be used to query an optimistic forecast scenario
*/
public static final String OPTIMISTIC = "optimistic";
/**
* Argument can be used to query a pessimistic forecast scenario
*/
public static final String PESSIMISTIC = "pessimistic";

/**
* Returns electric energy production for one day
*
* @param date
* @param args possible arguments from this interface
* @return QuantityType<Energy> in kW/h
*/
QuantityType<Energy> getDay(LocalDate date, String... args);

/**
* Returns electric energy between two timestamps
*
* @param start
* @param end
* @param args possible arguments from this interface
* @return QuantityType<Energy> in kW/h
*/
QuantityType<Energy> getEnergy(Instant start, Instant end, String... args);

/**
* Returns electric power at one specific point of time
*
* @param timestamp
* @param args possible arguments from this interface
* @return QuantityType<Power> in kW
*/
QuantityType<Power> getPower(Instant timestamp, String... args);

/**
* Get the first date and time of forecast data
*
* @return date time
*/
Instant getForecastBegin();

/**
* Get the last date and time of forecast data
*
* @return date time
*/
Instant getForecastEnd();

/**
* Get TimeSeries for Power forecast
*
* @param mode QueryMode for optimistic, pessimistic or average estimation
* @return TimeSeries containing QuantityType<Power>
*/
TimeSeries getPowerTimeSeries(QueryMode mode);

/**
* Get TimeSeries for Energy forecast
*
* @param mode QueryMode for optimistic, pessimistic or average estimation
* @return TimeSeries containing QuantityType<Energy>
*/
TimeSeries getEnergyTimeSeries(QueryMode mode);

/**
* SolarForecast identifier
*
* @return unique String to identify solar plane
*/
String getIdentifier();
}
Loading