Mqtt to telegram at a specific time

Hi,

I have a mqtt temperature sensor, he is sending every 10 sec. the temperature in msg.payload.temperature. Now I want to send the temperature every morning via telegram to my cell phone. But i don't know how to do it.

What I tried is this: Normaly I would pu the http request for telegram instead of the debug.

I would be very thankdul if someone could help me.

[{"id":"b7172174.54be78","type":"tab","label":"Demo","disabled":false,"info":""},{"id":"34e90532.2c498a","type":"mqtt in","z":"b7172174.54be78","name":"Temp Büro","topic":"zigbee2mqtt/1 Temp Büro","qos":"2","datatype":"auto","broker":"c1318d39.47b658","x":483,"y":257,"wires":[["64161d1f.c342dc"]]},{"id":"64161d1f.c342dc","type":"json","z":"b7172174.54be78","name":"","property":"payload","action":"","pretty":false,"x":711,"y":257,"wires":[["37f522c7.7959a6"]]},{"id":"37f522c7.7959a6","type":"change","z":"b7172174.54be78","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":256,"wires":[["270bcde1.6383e2"]]},{"id":"3c875f9e.411678","type":"inject","z":"b7172174.54be78","name":"","topic":"Message 6:30","payload":"jetzt","payloadType":"flow","repeat":"","crontab":"30 06 * * *","once":false,"onceDelay":0.1,"x":478,"y":339,"wires":[["270bcde1.6383e2"]]},{"id":"270bcde1.6383e2","type":"function","z":"b7172174.54be78","name":"","func":"\n\nreturn msg;\n","outputs":1,"noerr":0,"x":1185,"y":349,"wires":[["a272415d.0ec4a8"]]},{"id":"a272415d.0ec4a8","type":"template","z":"b7172174.54be78","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Die Temperatur beträgt {{payload}} C","output":"str","x":1390,"y":350,"wires":[["e442844a.9810c"]]},{"id":"e442844a.9810c","type":"debug","z":"b7172174.54be78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1681,"y":230,"wires":[]},{"id":"c1318d39.47b658","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

why not put the value into a flow variable (see https://nodered.org/docs/user-guide/context) when it comes in. Then have another flow that is triggered (like you have it) by an inject set to fire at a precise time. That flow will grab the value from the flow variable and send it off via telegram.

I would do it like this


The top Inject simulates your temperature from MQTT, I have got it running every second so the action is easier to see.
The bottom one generates a tick every 10 seconds to trigger the telegram event. Obviously you would set that to trigger at the appropriate time each day rather than every 10 seconds. The Join node combines those into one message every second, then the Switch node passes on only the ones caused by the tick. The result is a message every 10 seconds (or once a day in your case) containing the temperature in msg.payload["your/mqtt/topic"].

[{"id":"f097ef3b.d1fd2","type":"inject","z":"d7ff0732.2f81d8","name":"Temperature every 1 second","topic":"some/mqtt/topic","payload":"72","payloadType":"num","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":213,"y":402,"wires":[["4e40a028.5d57d8"]]},{"id":"4f2979dd.33de3","type":"comment","z":"d7ff0732.2f81d8","name":"This simulates the MQTT input","info":"","x":207.5,"y":370,"wires":[]},{"id":"1476e711.b2e9f1","type":"inject","z":"d7ff0732.2f81d8","name":"Tick every 10 seconds","topic":"tick","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":235,"y":496,"wires":[["4e40a028.5d57d8"]]},{"id":"cc1128e0.fa5b3","type":"comment","z":"d7ff0732.2f81d8","name":"This generates a tick every 10 seconds","info":"","x":193.5,"y":462,"wires":[]},{"id":"4e40a028.5d57d8","type":"join","z":"d7ff0732.2f81d8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":436.5,"y":425,"wires":[["4f3d1dd8.36ba4c"]]},{"id":"c2c3d17e.c8c688","type":"debug","z":"d7ff0732.2f81d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":575,"y":513,"wires":[]},{"id":"4f3d1dd8.36ba4c","type":"switch","z":"d7ff0732.2f81d8","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"tick","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":561.5,"y":423,"wires":[["c2c3d17e.c8c688"]]},{"id":"799dffa6.6347e8","type":"comment","z":"d7ff0732.2f81d8","name":"Output every ten seconds","info":"","x":652,"y":388,"wires":[]}]

Thank you it is working wonderful. I tried both versions and decided to use the version of zenofmud.