Skip to content

Commit

Permalink
Merge branch 'main' into feature-addonxml
Browse files Browse the repository at this point in the history
  • Loading branch information
J-N-K authored Aug 16, 2022
2 parents 745f8bf + 8f745b0 commit fe597df
Show file tree
Hide file tree
Showing 49 changed files with 2,190 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
system.config.jsonaddonservice.showUnstable.label = Prikaži nestabilne razširitve
system.config.jsonaddonservice.showUnstable.description = Vključi vnose, ki nimajo oznake "satbilno". Te razširitve so namenjene testiranju in niso primerne za produkcijske sisteme.
system.config.jsonaddonservice.urls.label = URL naslov razširitvene storitev
system.config.jsonaddonservice.urls.description = Pridobi Json pipe (|) ločen seznam URL naslovov, ki omogočajo storitve tretjih oseb preko Json datotek. Paketi, ki so pridobljeni preko razširitvenih storitev tretjih oseb, so lahko pomanjkljivo pregledane in lahko pošodujejo sistem.
system.config.marketplace.apiKey.label = API ključ za openhab.org skupnost
system.config.marketplace.apiKey.description = Določi API ključ za rabo na forumu skupnosti (za osebje in kuratorje - to npr. omogoča gledanje vsebin, ki še niso bile preverjene in so skrite pred splošno javnostjo). Pustite prazno, če ključa nimate.
system.config.marketplace.enable.label = Vklopi trgovino skupnosti
system.config.marketplace.enable.description = Če je izklopljeno, razširitve trgovine skupnosti ne bodo prikazane. Že nameščene razširitve bodo še vedno na voljo.
system.config.marketplace.showUnpublished.label = Prikaži neobjavljene vnose
system.config.marketplace.showUnpublished.description = Vključi vnose, ki niso bili označeni za objavo. Opozorilo\: to lahko vključuje vnose, ki še niso pripravljeni in so lahko nedelujoči ali celo pokvarijo namestitev. Vklopite na lastno odgovornost, zoglj za namene testiranja.

service.system.marketplace.label = Trgovina skupnosti
service.system.jsonaddonservice.label = Storitev za Json razširitve tretjih uporabnikov
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
system.config.audio.defaultSource.label = privzeti vir
system.config.audio.defaultSource.description = Privzeti vir zvoka, če ni določeno drugače.
system.config.audio.defaultSink.label = privzeti ponor
system.config.audio.defaultSink.description = Privzeti ponor zvoka, če ni določeno drugače.

service.system.audio.label = zvok
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package org.openhab.core.automation.internal.module.handler;

import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Dictionary;
import java.util.Hashtable;
Expand Down Expand Up @@ -57,14 +58,17 @@ public class DateTimeTriggerHandler extends BaseTriggerModuleHandler

public static final String MODULE_TYPE_ID = "timer.DateTimeTrigger";
public static final String CONFIG_ITEM_NAME = "itemName";
public static final String CONFIG_TIME_ONLY = "timeOnly";

private static final DateTimeFormatter CRON_FORMATTER = DateTimeFormatter.ofPattern("s m H d M * uuuu");
private static final DateTimeFormatter CRON_TIMEONLY_FORMATTER = DateTimeFormatter.ofPattern("s m H * * * *");

private final Logger logger = LoggerFactory.getLogger(DateTimeTriggerHandler.class);

private final CronScheduler scheduler;
private final String itemName;
private String cronExpression = CronAdjuster.REBOOT;
private Boolean timeOnly = false;

private @Nullable ScheduledCompletableFuture<?> schedule;
private @Nullable ServiceRegistration<?> eventSubscriberRegistration;
Expand All @@ -78,6 +82,8 @@ public DateTimeTriggerHandler(Trigger module, CronScheduler scheduler, ItemRegis
logger.warn("itemName is blank in module '{}', trigger will not work", module.getId());
return;
}
this.timeOnly = ConfigParser.valueAsOrElse(module.getConfiguration().get(CONFIG_TIME_ONLY), Boolean.class,
false);
Dictionary<String, Object> properties = new Hashtable<>();
properties.put("event.topics", "openhab/items/" + itemName + "/*");
eventSubscriberRegistration = bundleContext.registerService(EventSubscriber.class.getName(), this, properties);
Expand Down Expand Up @@ -173,7 +179,9 @@ private void process(Type value) {
if (value instanceof UnDefType) {
cronExpression = CronAdjuster.REBOOT;
} else if (value instanceof DateTimeType) {
cronExpression = ((DateTimeType) value).getZonedDateTime().format(CRON_FORMATTER);
boolean itemIsTimeOnly = ((DateTimeType) value).toString().startsWith("1970-01-01T");
cronExpression = ((DateTimeType) value).getZonedDateTime().withZoneSameInstant(ZoneId.systemDefault())
.format(timeOnly || itemIsTimeOnly ? CRON_TIMEONLY_FORMATTER : CRON_FORMATTER);
startScheduler();
} else {
logger.warn("Received {} which is not an accepted value for trigger of type '{}", value, MODULE_TYPE_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@
"label": "Item",
"description": "the name of the item",
"required": true
},
{
"name": "timeOnly",
"type": "BOOLEAN",
"label": "Time only",
"description": "Specifies whether only the time of the item should be compared or the date and time.",
"options": [
{
"label": "Yes",
"value": "true"
},
{
"label": "No",
"value": "false"
}
]
}
]
}
Expand Down
Loading

0 comments on commit fe597df

Please sign in to comment.