Can input and output resources be aggregated?

i have read the coding guide and i have searched on the forum about that.

i have in my code something like this:

void streamData(void *parameter) {
 	for (;;) {
		thing["leavening cell 1"] >> [](pson& out){
			out["Temperatures1"] = sensor1Temp;
			out["cold1"] = frigo1Status;
			out["hot1"] = stufa1Status;
		vTaskDelay(5000 / portTICK_PERIOD_MS);
 void setup() {
	thing["Temperatures SET 1"] << [](pson & in) {
		(in.is_empty()) ? in = cella1SetT; : cella1SetT = in;
	xTaskCreate(streamData, "Stream Data to", 10000, NULL, 1, NULL);


in the api i see “temperatureSET1” and “leavening cell 1”.
can i aggregate “temperatureSET1”, that is an input resources, with the resources in “leavening cell 1” that are output resources?


Yes sure, I guess something like this should work:

	thing["leavening cell 1"] >> [](pson & in, pson & out){
        (in["temperatureSET1"] .is_empty()) ? in["temperatureSET1"]  = cella1SetT; : cella1SetT = in["temperatureSET1"] ;
		out["Temperatures1"] = sensor1Temp;
		out["cold1"] = frigo1Status;
		out["hot1"] = stufa1Status;

Try it and let me know how it goes :wink:

i get
no match for 'operator>>' (operand types are 'thinger::thinger_resource' and 'setup()::<lambda(protoson::pson&, protoson::pson&)>')
on compiling
i have try to compile with = operator instead >> and it’s work.
a last question :pray:
how often are the input/output resources updated?
Thank you again :grin:

Wow that’s cool that you figured it out, I havent worked with an input output resource, but I knew it can be defined.

They are updated as often as they are consulted, when you consult a “thing”, it updates the value and reports (basically always reports the current value), even I’m not sure if you know that you can add some routine and or code to the “thing” and it will be executed every time the “thing” is consulted.

Even in the case the input output resource, you can add two values as inputs, and do mathematic operations and show the result as output, for example.

You are welcome, any other doubt you know what to do.

Best regards,