Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Stream() doesnt provide the path with eventType "patch" #321

Open
opit7 opened this issue Mar 15, 2018 · 6 comments
Open

Stream() doesnt provide the path with eventType "patch" #321

opit7 opened this issue Mar 15, 2018 · 6 comments
Milestone

Comments

@opit7
Copy link

opit7 commented Mar 15, 2018

When using stream() and the eventType is "patch" it doesnt show the "path" of the patched object.

code

putpatch

Any suggestions?

@piyushcharpe
Copy link

Even I am deling with the same issue.
I am getting the path but path before the expected child and not getting data at all.
ex. (Database/Artist/Singer) --> This is what I am recieving.
(Database/Artist/Singer/SingerName) --> This is what I am expecting

In stream function when I am giving the complete path (i.e Database/Artist/Singer/SingerName),
at that time I am recieveing the correct data but it prints eventType as "put"

I am uploading the data on the Firebase using the android app and recieving the data using Nodemcu

I searched a lot for this on net but miserably failed to get the solution,
I request contributors to have a look on this issue.
I wil really appreciate that.

@proppy
Copy link
Contributor

proppy commented Jun 15, 2018

Sorry for the late reply

Seems similar to #335

Can you turn on debugging:
http://arduino-esp8266.readthedocs.io/en/latest/Troubleshooting/debugging.html
And paste the serial log from HttpClient here?

Thanks in advance.

@proppy proppy changed the title Stream() doesnt provide the path Stream() doesnt provide the path with eventType "patch" Jun 15, 2018
@proppy proppy added this to the 0.1 milestone Jun 15, 2018
@kptdobe
Copy link
Contributor

kptdobe commented Nov 18, 2018

Actually, it works but really not straight forward to use...

If you output the JsonVariant from the event, data are here:

FirebaseObject event = Firebase.readEvent();
JsonVariant v = event.getJsonVariant("data");
String data = v.as<String>();
println(data);

This outputs something like:

{"sensor1":"value1","sensor2":"value2",}

(assuming you patch sensor1 and sensor2 values).

To fetch the data you need to prefix the paths with /data: event.getString("/data/sensor1") gives you value1!!

There is one thing which is not possible to achieve: test if a property has been changed or read multiple properties. You would need to use event.failed() or event.success() to know if the previous getString was successful, this would allow you to do something like:

FirebaseObject event = Firebase.readEvent();
String v1 = event.getString("/data/sensor1");
if(event.success()) {
  // do something with new v1 value
}

String v2 = event.getString("/data/sensor2");
if(event.success()) {
  // do something with new v2 value
}

The error mechanism in FirebaseObject never resets the error message which mean you cannot "inspect" the payload and check if one of your property has been changed or read 2 of them and know if they have been changed.
I'll provide a PR to fix that but the whole logic would need to be reviewed because it is really complex to have a common code to handle put and patch...

@keshij555
Copy link

anybody solve that yet...

@keshij555
Copy link

I also want that if data triggering on firebase so I got data and path.

@keshij555
Copy link

and if its not possible so plz suggest me other solution/way for the same problem.

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