Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Question: Are "Location" and "Call" official itemtype? #3104

Closed
lewie opened this issue Aug 28, 2015 · 14 comments
Closed

Question: Are "Location" and "Call" official itemtype? #3104

lewie opened this issue Aug 28, 2015 · 14 comments

Comments

@lewie
Copy link
Contributor

lewie commented Aug 28, 2015

Hello, I can find Information about "Location" and "Call" in Sourcecode, but not in Wiki: https://github.com/openhab/openhab/wiki/Explanation-of-items#itemtype

So, are they deprecated or is there another reason for there hide and seek. ;-)

I am working at a new Bundle so I need to know about.

Thanks
Helmut

@watou
Copy link
Contributor

watou commented Aug 28, 2015

When I try to use a Location item with a perfectly valid lat,lon string of the form "99.9999999,-99.9999999" it logs this:

[WARN ] [ore.internal.items.ItemUpdater] - InstantiationException on org.openhab.core.library.types.PointType

(1.7.1 core and bindings). If I change the item to a String item, I see its value correctly.

@lewie
Copy link
Contributor Author

lewie commented Aug 31, 2015

Hello @watou,
yes, something goes wrong with these items?

@teichsta: Do "Location" and "Call" have a future in OpenHab1/2?

Some Tests in OpenHab 1:

  • Items:
Call                        Call_Item           (All)
Location                    Location_Item       (All)
  • Rules:
import org.openhab.core.library.types.*
import org.openhab.library.tel.items.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.openhab.core.library.items.LocationItem
import org.openhab.library.tel.types.CallType
import org.openhab.library.tel.items.CallItem

rule "Location_Item Demo"
    when
        Time cron "0/5 * * * * ?"
    then    
        var PointType t1 = new PointType("49.71721,11.13682")
        var PointType t2 = new PointType("52.5200066,13.4049540")

        logInfo("Location_Item:","          Location_Item= "+Location_Item)
        logInfo("Location_Item:","          t1: "+t1.toString())
        logInfo("Location_Item:","          t2: "+t2.toString())

        postUpdate("Location_Item",t1)
        sendCommand("Location_Item",t2)
    end

rule "Call_Item Demo"
    when
        Time cron "3/5 * * * * ?"
    then    
        var CallType c1 = new CallType("091916255252##01792239944")
        var CallType c2 = new CallType("091916255254##01792239946")

        logInfo("Call_Item:","          Call_Item= "+Call_Item)
        logInfo("Call_Item:","          c1: "+c1.toString())
        logInfo("Call_Item:","          c2: "+c2.toString())

        postUpdate("Call_Item",c1)
        sendCommand("Call_Item",c2)
    end
  • Result:
15:25:58.002 [DEBUG] [.o.m.r.i.engine.ExecuteRuleJob:53   ] - Executing scheduled rule 'Call_Item Demo'
15:25:58.051 [INFO ] [penhab.model.script.Call_Item::53   ] -           Call_Item= Call_Item (Type=CallItem, State=Uninitialized)
15:25:58.077 [INFO ] [penhab.model.script.Call_Item::53   ] -           c1: 01792239944##091916255252
15:25:58.100 [INFO ] [penhab.model.script.Call_Item::53   ] -           c2: 01792239946##091916255254
15:25:58.160 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob:57   ] - Error during the execution of rule Call_Item Demo
java.lang.IllegalStateException: Could not invoke method: org.openhab.model.script.actions.BusEvent.postUpdate(org.openhab.core.items.Item,org.openhab.core.types.State) on instance: null
    at org.eclipse.xtext.xb...
Caused by: java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeMeth...

15:26:00.001 [DEBUG] [.o.m.r.i.engine.ExecuteRuleJob:53   ] - Executing scheduled rule 'Location_Item Demo'
15:26:00.006 [INFO ] [.o.model.script.Location_Item::53   ] -           Location_Item= Location_Item (Type=LocationItem, State=Uninitialized)
15:26:00.008 [INFO ] [.o.model.script.Location_Item::53   ] -           t1: 49,72°N, 11,14°W, 0,00 m
15:26:00.010 [INFO ] [.o.model.script.Location_Item::53   ] -           t2: 52,52°N, 13,40°W, 0,00 m
15:26:00.016 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob:57   ] - Error during the execution of rule Location_Item Demo
java.lang.IllegalStateException: Could not invoke method: org.openhab.model.script.actions.BusEvent.postUpdate(org.openhab.core.items.Item,org.openhab.core.types.State) on instance: null
    at org.eclipse.xtext.xbas...
Caused by: java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.Nat...

Rgds
Helmut

@teichsta teichsta added this to the 1.8.0 milestone Aug 31, 2015
@teichsta
Copy link
Member

Hi,

So, are they deprecated or is there another reason for there hide and seek. ;-)

no, both types are valid and not deprecated! If they are not working i would consider this a critical bug.

Note: there are ongoing discussion about the purpose and in depth implementation of the CallItem/Type in ESH (see eclipse-archived/smarthome#236). Any chance to investigate what the problem could be?

Best, Thomas E.-E.

@watou
Copy link
Contributor

watou commented Aug 31, 2015

@lewie, I changed your rules from postUpdate("item", state) to item.postUpdate(state) and I saw no failures in the log:

2015-08-31 21:36:55.013 [INFO ] [.o.model.script.Location_Item:] -           Location_Item= Location_Item (Type=LocationItem, State=49.72°N, 11.14°W, 0.00 m)
2015-08-31 21:36:55.019 [INFO ] [.o.model.script.Location_Item:] -           t1: 49.72°N, 11.14°W, 0.00 m
2015-08-31 21:36:55.023 [INFO ] [.o.model.script.Location_Item:] -           t2: 52.52°N, 13.40°W, 0.00 m
2015-08-31 21:36:58.012 [INFO ] [penhab.model.script.Call_Item:] -           Call_Item= Call_Item (Type=CallItem, State=01792239946##091916255254)
2015-08-31 21:36:58.016 [INFO ] [penhab.model.script.Call_Item:] -           c1: 01792239944##091916255252
2015-08-31 21:36:58.020 [INFO ] [penhab.model.script.Call_Item:] -           c2: 01792239946##091916255254

I don't know why passing the item name instead as the first argument doesn't work in these cases.

Also, I can see in the code that sendCommand("Location_Item",t2) or Location_Item.sendCommand(t2) won't work because LocationItems do not accept Commands, so I commented out that line.

@teichsta
Copy link
Member

won't work because LocationItems do not accept Commands, so I commented out that line.

good catch! I didn't know that by now :-) I would consider this as flaw since it should be possible to send a location command to e.g. a lawn mower to the autonomously driving car, etc. …

@watou
Copy link
Contributor

watou commented Aug 31, 2015

Agreed; PointType ought to be an acceptedCommandType for LocationItems. Should I make a PR to add that?

I also think I just noticed why I could not post an update to the LocationItem -- PointType does not have a zero-arg constructor; all types need a zero-arg ctor per this line.

watou added a commit to watou/openhab that referenced this issue Aug 31, 2015
teichsta added a commit that referenced this issue Sep 1, 2015
Allow Location items to receive commands and updates (ref #3104)
paolodenti pushed a commit to paolodenti/openhab that referenced this issue Sep 28, 2015
paolodenti pushed a commit to paolodenti/openhab that referenced this issue Oct 1, 2015
@steve-bate
Copy link
Contributor

@watou @teichsta I'm reviewing open critical bug reports. It looks like merged PR #3104 partially fixes this issue. Can someone summarize what remains to be fixed and if that is still a critical bug? Thanks.

@teichsta
Copy link
Member

@lewie could you please summarise if and what is still open here?

@teichsta
Copy link
Member

@lewie any chance to have a look at this one in the coming days?

@lewie
Copy link
Contributor Author

lewie commented Dec 26, 2015

Hello @teichsta and all, Merry Christmas :-)

tested in 1.8 SNAPSHOT:

DEFAULT RULES:
Both, Location and Call Items are working with style
item.postUpdate(state)
item.sendCommand(state)

Get Errors for both Location and Call Items with style
postUpdate("item", state)
sendCommand("item", state)

Errors:


2015-12-26 17:28:50.065 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob] - Error during the execution of rule Call_Item Demo1
java.lang.IllegalStateException: Could not invoke method: org.openhab.model.script.actions.BusEvent.postUpdate(org.openhab.core.items.Item,java.lang.Number) on instance: null
...

2015-12-26 17:36:10.009 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob] - Error during the execution of rule Call_Item Demo1
java.lang.IllegalStateException: Could not invoke method: org.openhab.model.script.actions.BusEvent.sendCommand(org.openhab.core.items.Item,java.lang.String) on instance: null

...

2015-12-26 17:29:00.075 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob] - Error during the execution of rule Location_Item Demo1
java.lang.IllegalStateException: Could not invoke method: org.openhab.model.script.actions.BusEvent.postUpdate(org.openhab.core.items.Item,java.lang.Number) on instance: null
...

2015-12-26 17:40:40.056 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob] - Error during the execution of rule Location_Item Demo1
java.lang.IllegalStateException: Could not invoke method: org.openhab.model.script.actions.BusEvent.sendCommand(org.openhab.core.items.Item,java.lang.String) on instance: null
...

Used Rules:

rule "Location_Item Demo1"
    when
        Time cron "0/20 * * * * ?"
    then    
        var PointType t1 = new PointType("39.71721,21.13682")
        var PointType t2 = new PointType("52.5200066,13.4049540")
        postUpdate("Location_Item",t1)
        sendCommand("Location_Item",t2)

    end

rule "Location_Item Demo2"
    when
        Time cron "5/20 * * * * ?"
    then    
        var PointType t1 = new PointType("39.71721,21.13682")
        var PointType t2 = new PointType("52.5200066,13.4049540")
        Location_Item.postUpdate(t1)
        Location_Item.sendCommand(t2)
    end

rule "Call_Item Demo1"
    when
        Time cron "10/20 * * * * ?"
    then    
        var CallType c1 = new CallType("0232323232352##05454545454")
        var CallType c2 = new CallType("0232323232354##05454545456")
        postUpdate("Call_Item",c1)
        sendCommand("Call_Item",c2)

    end

rule "Call_Item Demo2"
    when
        Time cron "15/20 * * * * ?"
    then    
        var CallType c1 = new CallType("0232323232352##05454545454")
        var CallType c2 = new CallType("0232323232354##05454545456")
        Call_Item.postUpdate(c1)
        Call_Item.sendCommand(c2)
    end

JSR223 RULES:
Get Errors with call Item:
seems to be a classloader problem with org.openhab.library.tel.types.CallType

2015-12-26 17:44:00.065 [WARN ] [.c.i.events.EventPublisherImpl] - given new state is NULL, couldn't post update for 'Call_Item'
2015-12-26 17:44:00.065 [WARN ] [.c.i.events.EventPublisherImpl] - given command is NULL, couldn't send command to 'Call_Item'

Used JS script:

var itemTypeLocationCall = new Rule(){
    getEventTrigger: function(){
        return [
            new TimerTrigger("0 0/1 * * * ?")
        ];
    },
    execute: function(event){
        var p = new PointType(new DecimalType(49.71721), new DecimalType(11.13682));
        be.postUpdate("Location_Item",p);
        var p = new PointType(new DecimalType(59.71721), new DecimalType(21.13682));
        be.sendCommand("Location_Item",p);


        var c = new CallType("091916255250##01792239943");
        be.postUpdate("Call_Item",c);
        var c = new CallType("091916255250##01792239944");
        be.sendCommand("Call_Item",c);
    }
};
function getRules(){return new RuleSet([itemTypeLocationCall]);}

@teichsta
Copy link
Member

thanks for this update @lewie … so still something left to do unfortunately!

@lewie
Copy link
Contributor Author

lewie commented Jan 8, 2016

Oh, sorry @teichsta, I just noticed this.

Can not do it jet.
Or in other words, it would take too long to incorporate me to dive deep.

For DEFAULT RULES: and its writing style problem, I think we need a xText specialist.
For LocationItem I do not know what to do yet.

For CallItem the first thing I think, is to integrate it correct:
One of the reasons is certainly that:

org.openhab.library.tel.types.CallType should move to other Types
org.openhab.core.library.types.CallType

org.openhab.library.tel.items.CallItem should move to other Item Classes
org.openhab.core.library.items.CallItem
and
org.openhab.library.tel.TelItemFactory should move to
org.openhab.core.library.TelItemFactory

But of this, these bundles are affected:
org.openhab.binding.asterisk
org.openhab.binding.freeswitch
org.openhab.binding.fritzbox
org.openhab.binding.fritzboxtr064
org.openhab.core.compat1x
org.openhab.core.jsr223
org.openhab.library.tel
org.openhab.persistence.jpa

Hmm...

Helmut

@teichsta teichsta modified the milestones: 1.8.0, 1.8.1 Jan 10, 2016
@teichsta teichsta modified the milestones: 1.8.1, 1.8.2 Feb 2, 2016
@teichsta teichsta modified the milestones: 1.8.2, 1.8.1 Feb 2, 2016
@teichsta teichsta modified the milestones: 1.8.2, 1.9.0 Mar 21, 2016
@9037568
Copy link
Contributor

9037568 commented Dec 22, 2016

Since the core is no longer here, should we create a new issue for this in ESH?

( @watou, @lewie )

@9037568
Copy link
Contributor

9037568 commented Jan 26, 2020

Closing due to inactivity

@9037568 9037568 closed this as completed Jan 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants