We currently have a fleet of TRB141 devices, which we control using mqtt modbus commands. For most of our use cases we need to trigger a relay to ‘open’ and then ‘close’ after x seconds. Is there some way to program the device so that it will automatically return to a ‘closed’ or ‘open’ position after x seconds? I know this is possible with the http endpoints query parameters, but can it also be done with mqtt or preprogrammed on the device?
Hi,
I have a similar case with yours. I just did a simple custom script where it will check the status of the relay. If it is the same, it will invert the state for a duration (in seconds).
> #!/bin/ash
> delay=5
> while true; do
> if [ "$(ubus call ioman.relay.relay0 status | jsonfilter -e '@.state')" = "closed" ]; then
> sleep $delay
> ubus call ioman.relay.relay0 update '{"state":"open"}'
> else
> sleep 1 # Sleep for 1 second to avoid constant looping
> fi
> done
Note: Just change the value of the variable “delay” to your required duration.
To run this script, you can refer to this link:
https://wiki.teltonika-networks.com/view/User_Scripts_examples
Once the script is running, you can trigger this by Modbus MQTT gateway by changing the relay status.
Hope this helps!
interesting, how do I make sure this script is still running after rebooting?
Hi,
You can paste the scripts here. Administration → Maintenance → Custom Scripts
Once the device booted up, it will run the script continuously.
thanks! I’ll give it a try.
@just.here2help one thing is still unclear: the device has latching relays and relays that are normally open or normally closed. Shouldn’t there be someplace in the UI where I can configure that it should return to closed or open position? Otherwise why would they mention that it has a ‘normal’ position if the relay does not behave like that?
This topic was automatically closed after 15 days. New replies are no longer allowed.