|
| 1 | +/* |
| 2 | + * Copyright 2025, OpenRemote Inc. |
| 3 | + * |
| 4 | + * See the CONTRIBUTORS.txt file in the distribution for a |
| 5 | + * full listing of individual contributors. |
| 6 | + * |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU Affero General Public License as |
| 9 | + * published by the Free Software Foundation, either version 3 of the |
| 10 | + * License, or (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU Affero General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Affero General Public License |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | +package org.openremote.extension.ems.agent; |
| 21 | + |
| 22 | +import jakarta.persistence.Entity; |
| 23 | +import org.openremote.model.asset.Asset; |
| 24 | +import org.openremote.model.asset.AssetDescriptor; |
| 25 | +import org.openremote.model.attribute.MetaItem; |
| 26 | +import org.openremote.model.value.AbstractNameValueHolder; |
| 27 | +import org.openremote.model.value.AttributeDescriptor; |
| 28 | +import org.openremote.model.value.MetaItemType; |
| 29 | +import org.openremote.model.value.ValueType; |
| 30 | + |
| 31 | +import java.util.Optional; |
| 32 | + |
| 33 | +import static org.openremote.model.Constants.*; |
| 34 | + |
| 35 | +@Entity |
| 36 | +public class EmsDayAheadAsset extends Asset<EmsDayAheadAsset> { |
| 37 | + |
| 38 | + public static final AttributeDescriptor<String> COLLECT_TIME_FORECASTS = new AttributeDescriptor<>("collectTimeForecasts", ValueType.TEXT); |
| 39 | + |
| 40 | + public static final AttributeDescriptor<String> LAST_UPDATE_FORECASTS = new AttributeDescriptor<>("lastUpdateForecasts", ValueType.TEXT, |
| 41 | + new MetaItem<>(MetaItemType.DATA_POINTS_MAX_AGE_DAYS, 7), |
| 42 | + new MetaItem<>(MetaItemType.READ_ONLY), |
| 43 | + new MetaItem<>(MetaItemType.STORE_DATA_POINTS) |
| 44 | + ); |
| 45 | + |
| 46 | + public static final AttributeDescriptor<Double> TARIFF_EXPORT_DAY_AHEAD = new AttributeDescriptor<>("tariffExportDayAheadForecast", ValueType.NUMBER, |
| 47 | + new MetaItem<>(MetaItemType.DATA_POINTS_MAX_AGE_DAYS, 7), |
| 48 | + new MetaItem<>(MetaItemType.READ_ONLY), |
| 49 | + new MetaItem<>(MetaItemType.STORE_DATA_POINTS) |
| 50 | + ).withUnits("EUR", UNITS_PER, UNITS_KILO, UNITS_WATT, UNITS_HOUR); |
| 51 | + |
| 52 | + public static final AttributeDescriptor<Double> TARIFF_IMPORT_DAY_AHEAD = new AttributeDescriptor<>("tariffImportDayAheadForecast", ValueType.NUMBER, |
| 53 | + new MetaItem<>(MetaItemType.DATA_POINTS_MAX_AGE_DAYS, 7), |
| 54 | + new MetaItem<>(MetaItemType.READ_ONLY), |
| 55 | + new MetaItem<>(MetaItemType.STORE_DATA_POINTS) |
| 56 | + ).withUnits("EUR", UNITS_PER, UNITS_KILO, UNITS_WATT, UNITS_HOUR); |
| 57 | + |
| 58 | + public static final AttributeDescriptor<Boolean> USE_TARIFF_DAY_AHEAD_FORECASTS = new AttributeDescriptor<>("useTariffDayAheadForecasts", ValueType.BOOLEAN); |
| 59 | + |
| 60 | + |
| 61 | + public static final AssetDescriptor<EmsDayAheadAsset> DESCRIPTOR = new AssetDescriptor<>("calendar-clock", "000000", EmsDayAheadAsset.class); |
| 62 | + |
| 63 | + protected EmsDayAheadAsset() { |
| 64 | + } |
| 65 | + |
| 66 | + public EmsDayAheadAsset(String name) { |
| 67 | + super(name); |
| 68 | + } |
| 69 | + |
| 70 | + |
| 71 | + public Optional<String> getCollectTimeForecasts() { |
| 72 | + return getAttribute(COLLECT_TIME_FORECASTS).flatMap(AbstractNameValueHolder::getValue); |
| 73 | + } |
| 74 | + |
| 75 | + public Optional<String> getLastUpdateForecasts() { |
| 76 | + return getAttribute(LAST_UPDATE_FORECASTS).flatMap(AbstractNameValueHolder::getValue); |
| 77 | + } |
| 78 | + |
| 79 | + public Optional<Boolean> getUseTariffDayAheadForecasts() { |
| 80 | + return getAttribute(USE_TARIFF_DAY_AHEAD_FORECASTS).flatMap(AbstractNameValueHolder::getValue); |
| 81 | + } |
| 82 | + |
| 83 | + |
| 84 | + public EmsDayAheadAsset setCollectTimeForecasts(String value) { |
| 85 | + getAttributes().getOrCreate(COLLECT_TIME_FORECASTS).setValue(value); |
| 86 | + return this; |
| 87 | + } |
| 88 | + |
| 89 | + public EmsDayAheadAsset setUseTariffDayAheadForecasts(Boolean value) { |
| 90 | + getAttributes().getOrCreate(USE_TARIFF_DAY_AHEAD_FORECASTS).setValue(value); |
| 91 | + return this; |
| 92 | + } |
| 93 | + |
| 94 | +} |
0 commit comments