[pythonscripting] Fix python timedelta to java duration mapping (#18671)
* fix python timedelta to java duration mapping * fix duration accuracypull/18644/head
parent
b93c093ef4
commit
4ea61d38dd
|
@ -80,7 +80,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<connectionUrl>scm:git:https://github.com/openhab/openhab-python</connectionUrl>
|
<connectionUrl>scm:git:https://github.com/openhab/openhab-python</connectionUrl>
|
||||||
<checkoutDirectory>${project.build.directory}/python</checkoutDirectory>
|
<checkoutDirectory>${project.build.directory}/python</checkoutDirectory>
|
||||||
<scmVersion>v1.0.0-rc1</scmVersion>
|
<scmVersion>v1.0.0-rc2</scmVersion>
|
||||||
<scmVersionType>tag</scmVersionType>
|
<scmVersionType>tag</scmVersionType>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class PythonScriptEngine
|
||||||
.targetTypeMapping(Value.class, Duration.class,
|
.targetTypeMapping(Value.class, Duration.class,
|
||||||
// picking two members to check as Duration has many common function names
|
// picking two members to check as Duration has many common function names
|
||||||
v -> v.hasMember("total_seconds") && v.hasMember("total_seconds"),
|
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)
|
HostAccess.TargetMappingPrecedence.LOW)
|
||||||
|
|
||||||
// Translate python item to org.openhab.core.items.Item
|
// Translate python item to org.openhab.core.items.Item
|
||||||
|
|
Loading…
Reference in New Issue