<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Nodemanager: How to control a local output from a local input?]]></title><description><![CDATA[<p dir="auto">I am trying to make a temperature control system that has a temperature sensor and a relay.<br />
I use an ESP32 and set it op as gateway. The sensor and relay are connected to the ESP32<br />
The sensor and relay should form a closed loop and should be able to run independently from the (Domoticz) controller.<br />
I want to use the Nodemanager to be able to track the temperature and relay state.<br />
In my first test I can read my sensor and I can switch my relay from Domoticz.<br />
I tried to add some code to the loop() to read the temperature locally and print it to the serial port:<br />
When I e.g.  try to print  Tsensor.getChild(0)-&gt;getValueString()  it throws an error.<br />
My question: what is the proper way to do this?<br />
How can I  get the sensor value and set the relay?<br />
Any suggestions are much appreciated</p>
]]></description><link>https://forum.mysensors.org/topic/11895/nodemanager-how-to-control-a-local-output-from-a-local-input</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 17:13:25 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/11895.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 30 Jan 2022 21:01:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Nodemanager: How to control a local output from a local input? on Sat, 05 Feb 2022 16:24:43 GMT]]></title><description><![CDATA[<p dir="auto">Reply to myself:<br />
Looking thought the sources and the forum found out that you can do this using hooks.<br />
so enabled hooking</p>
<pre><code>#define NODEMANAGER_HOOKING ON
</code></pre>
<p dir="auto">and added the reference to the hook to before.</p>
<pre><code>void before() {
 Tsensor.setMeasureTimerMode(TIME_INTERVAL);   // set timer 
 Tsensor.setMeasureTimerValue(1); // interval to 1 sec measurement

 Tsensor.setPostLoopHook(&amp;myfirstHook);
 ..etc.etc...
 nodemanager.before();
}
</code></pre>
<p dir="auto">And finally the hook</p>
<pre><code>void myfirstHook(Sensor* sensor){
  float temperature =  Tsensor.children.get(1)-&gt;getValueFloat()
  Serial.println(temperature);
  if (temperature&gt;setpoint) { 
        if (Relay.getStatus()==OFF){
        Relay.setStatus(ON);      // switch off
        } 
  

}
</code></pre>
<p dir="auto">The error that I got initially was caused by using the wrong child: 0  (it starts from 1).</p>
<p dir="auto">I wonder if it is possible to do interval &lt; 1 second?</p>
]]></description><link>https://forum.mysensors.org/post/111576</link><guid isPermaLink="true">https://forum.mysensors.org/post/111576</guid><dc:creator><![CDATA[A3V]]></dc:creator><pubDate>Sat, 05 Feb 2022 16:24:43 GMT</pubDate></item></channel></rss>