Reply to myself:
Looking thought the sources and the forum found out that you can do this using hooks.
so enabled hooking
#define NODEMANAGER_HOOKING ON
and added the reference to the hook to before.
void before() {
Tsensor.setMeasureTimerMode(TIME_INTERVAL); // set timer
Tsensor.setMeasureTimerValue(1); // interval to 1 sec measurement
Tsensor.setPostLoopHook(&myfirstHook);
..etc.etc...
nodemanager.before();
}
And finally the hook
void myfirstHook(Sensor* sensor){
float temperature = Tsensor.children.get(1)->getValueFloat()
Serial.println(temperature);
if (temperature>setpoint) {
if (Relay.getStatus()==OFF){
Relay.setStatus(ON); // switch off
}
}
The error that I got initially was caused by using the wrong child: 0 (it starts from 1).
I wonder if it is possible to do interval < 1 second?