Astro: getElevation has missing type object

Hi,

In my OpenHab project I am using the action “getElevation” to get the sun position in 30 minutes.
This is the code extract so far:

import java.time.ZonedDateTime
[...]
val sunActions = getActions("astro", "astro:sun:home")
var timeIn30Minutes = ZonedDateTime.now.plusMinutes(30)
var elevation_30min = sunActions.getElevation(timeIn30Minutes)
[...]

This seems to work but in the log viewer I get the following error message:
The method getElevation(ThingActions, ZonedDateTime) from the type AstroActions refers to the missing type Object

Does anybody has an idea what could be wrong and how to solve it?

Thank you!

Andreas

Just a quick look but I think the line starting with val should be var.

Hi Bruce,
I’ve replaces val by var but warning still occurs.
Best regards,
Andreas

OH 2.5 or OH 3?

It’s OH 2.5.10.

Seems like the same issue for the getAzimuth as i psoted here:

Seems so. Do you have any solution available?

I played with the QuantityType<T> in rules and i think the <Angle> is the Problem.

If i create an QuantityType<Number> in a rule, it is working, for example:

val QuantityType<Number> test1 = new QuantityType("5")

But when i try to create a QuantityType<Angle> i get an error:

val QuantityType<Angle> test2 = new QuantityType("5")
Angle cannot be resolved to a type.(org.eclipse.xtext.diagnostics.Diagnostic.Linking)

The getElevation(timestamp) function in the AstroActions.java is defined as a QuantityType<Angle> which is causing the warning

 public static @Nullable QuantityType<Angle> getElevation(ThingActions actions, @Nullable ZonedDateTime date) {
        return ((AstroActions) actions).getElevation(date);
    }

So I think the correct definition of the getAzimuth() and getElevation() should be with the generic type <Number> and not <Angle>

Can or should i create an issue of this on github?

Hi Tobias,

Thanks for your investigation! This looks reasonable but I am unsure about the suggested solution.
Are there two possible solutions?

  • Change return type to QuantityType<Number> OR
  • Change return((AstroActions)actions).getElevation(date) to new QuantityType<>(((AstroActions)actions).getElevation(date), SmartHomeUnits.DEGREE_ANGLE);

Nevertheless it looks like an issue :slight_smile:

This is broken with the OH3 as well. I’m trying to follow the example at https://www.openhab.org/addons/bindings/astro/#getazimuth-timestamp

sorry for the delay, but i’ve finally created an issue:

Hi Tobias! Thank you! Hope it will be fixed for OpenHab 2.x and 3.x, too.

Does somebody has any information when it will be fixed?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.