Creation of MQTT timer which can be call by Node red "call service" node

I am building an irrigation controller (ESP32) which uses MQTT to communicate with Home assistant. The entities on the device include a series of switches and associated timer (in this case 12 of each) for turning zones on and off.

Solution overview
I am using the MQTT switch for the switches as this allows the use of the Node-red call service “switch” domain and all the functionality that comes with it.

I am unable to find an equivalent for the timer although the Node-red “call service” node does have a “Timer” domain. The key difference is that I need to pass the “duration” to the MQTT entity. The node has a property of duration which can be used to set the duration, but I’m not sure how the integration works with HA, and hence, how I should configure the MQTT entity to pick it up. Effectively the timer is a switch with a property of duration. The MQTT switch does not have properties/functions (like the MQTT light).

Options I’ve considered
One option is to use the MQTT domain in the node-red “call service” node and communicate directly with the device. But I’m sure there is a simple solution to pass a property to the MQTT switch.

I had a quick look at the Timer helper, but I’m not sure I can use it to send messages to the ESP32(via mqtt).

Any suggestions would be much appreciated.

Thanking you in advance.

You will need to publish the value to the topic of the entity you want to update. You can use either a call service or an mqtt out node.

Thanks for your response. Apologies for the tardiness in replying.

I’m not sure I’ve fully understood your suggestion. Is there a way to publish to topic in the Node red “call service” node? If I did that, would it update an attribute in MQTT switch?

For the time being, I’ve decided to simply use the MQTT node.

Many thanks for your time.

Yes, the mqtt node and publish from a call service is basically the same thing.


   "payload":"This is great"

Apologies, I meant using the “call service” node with Domain as switch (rather than mqtt) - as I have defined the entity as a mqtt switch. Let me try this out.

Many thanks.