[pythonscripting] Fix python timedelta to java duration mapping (#18671)

* fix python timedelta to java duration mapping

* fix duration accuracy
pull/18644/head
Holger Hees 2025-05-10 19:25:01 +02:00 committed by GitHub
parent b93c093ef4
commit 4ea61d38dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -80,7 +80,7 @@
<configuration>
<connectionUrl>scm:git:https://github.com/openhab/openhab-python</connectionUrl>
<checkoutDirectory>${project.build.directory}/python</checkoutDirectory>
<scmVersion>v1.0.0-rc1</scmVersion>
<scmVersion>v1.0.0-rc2</scmVersion>
<scmVersionType>tag</scmVersionType>
</configuration>
</execution>

View File

@ -121,7 +121,7 @@ public class PythonScriptEngine
.targetTypeMapping(Value.class, Duration.class,
// picking two members to check as Duration has many common function names
v -> v.hasMember("total_seconds") && v.hasMember("total_seconds"),
v -> Duration.ofNanos(v.invokeMember("total_seconds").asLong() * 10000000),
v -> Duration.ofNanos(Math.round(v.invokeMember("total_seconds").asDouble() * 1000000000)),
HostAccess.TargetMappingPrecedence.LOW)
// Translate python item to org.openhab.core.items.Item