Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get all loads status - returns only first load #8

Open
dendeps opened this issue Aug 11, 2018 · 8 comments
Open

get all loads status - returns only first load #8

dendeps opened this issue Aug 11, 2018 · 8 comments

Comments

@dendeps
Copy link

dendeps commented Aug 11, 2018

Thank you very much for sharing your application!

I'm trying to get status of all light loads(there are more than 100 on site) with command "#10##" but getting only status of first load in response:

private static void example1() {
	        OpenWebNet
	            .newClient(defaultGateway(HOST))
	            .send(() -> "*#1*0##")
	            .subscribe(System.out::println);
	    }

[main] - connected!
[main] - read: 6|*#*1##
[main] - write: 7|*99*0##
[main] - read: 6|*#*1##
[main] - without credential
[main] - write: 7|*#1*0##
[main] - read: 9|*1*0*40##
OpenSession{request=*#1*0##, response=[{response=*1*0*40##}]}

Is it possible to get all responses as a list?

Thank you!

@niqdev
Copy link
Member

niqdev commented Aug 11, 2018

Hi,

I'm glad you find it useful.
Is that command suppose to return a list? What the library does, is simply to parse the response, so I suggest to try with netcat for example and see if the behaviour is the same.

If you need, here there is a bunch of examples.

Another way to get around that would be to generate a list of status command, for example this is how I would do it in Scala (I'm sure you can do something similar in Java but I'm not up to date with the latest jdk)

scala> (1 to 10).foldLeft(List.empty[String])((res, i) => s"*#1*$i##" :: res).reverse
res0: List[String] = List(*#1*1##, *#1*2##, *#1*3##, *#1*4##, *#1*5##, *#1*6##, *#1*7##, *#1*8##, *#1*9##, *#1*10##)

Let me know if the response from netcat and the lib are different.

In the wiki there is an example with nc

Thanks

@dendeps
Copy link
Author

dendeps commented Aug 12, 2018

Hi, thanks for reply!

Command #1*0## requests status for all devices, here is a screenshot:

https://ibb.co/dCUw5p

So it's convenient to use it to update status of devices on application start. But I receive only status of first device in a list.

Also, if you open Event connection to a gateway with *99*0## command, gateway will keep connection and send all events that happen in automation system. Is it possible to open and keep this connection to have all updates? IS it what not implemented Listen method supposed to do?

Thank you!

@niqdev
Copy link
Member

niqdev commented Aug 12, 2018

Hi,

I got your point, it's been ages since I haven't touched those logic. Try to dig deeper here. This is how I update the status in the app for all the lights. I hope it helps.

But I agree with you, I would have expected a list of status. Have you tried to download the project and debug the command to see where are discarded those frames?

And yes regarding the listen, I agree that it would be very handy, but I haven't implement it. Let me know if you are interested in do it.

Just for curiosity, are you working on a mobile or desktop app?

Thanks

@dendeps
Copy link
Author

dendeps commented Aug 17, 2018

Hi there,
Sorry been busy and didn't have time to check your reply.
So you use requestByEnvironment to update status? What does it exactly do, what OWN command is it using? I haven't found implementation in your code :)

Yeah I'd be interested to do it, let me know if it's possible.

I'm working on java spring web app, which will collect usage statistics and keep it in a database. Just to practice my skills on Java Spring, so it might be not useful to anyone except me )

@niqdev
Copy link
Member

niqdev commented Aug 22, 2018

Hi @dendeps, sorry for the late response but I was on holiday.

So the app under the hood uses only this library, looking at the code now I've just realized that what that command does is simply requesting N times the status, one for each light.

Probably is not ideal, but I did it like that cos was the simplest way to update the status of the model used by the UI.

Thanks for offering your help, could you please debug doRequest, in particular the methods read and parseMessages if somewhere they are loosing or truncating the response?

I think buiding your own project is the best way to learn!

@dendeps
Copy link
Author

dendeps commented Aug 27, 2018

Tried, haven't found yet. Can I contact you by email or any messenger to ask silly questions? )

@niqdev
Copy link
Member

niqdev commented Aug 27, 2018

Sure, I've sent you an invitation for a private chat on gitter

@niqdev
Copy link
Member

niqdev commented Aug 27, 2018

@dendeps by the way this is the gitter main page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants