I have just written script for Mikrotik dhcp server lease which send json/url command to Domoticz . Interested anybody?

Moderator: leecollings
Code: Select all
# *. by RouterOS
#
# DHCP Leases to Domoticz
# On-Lease Script
#
# Phones MAC
:global RomekMAC "AA:AA:AA:AA:AA:AA";
:global GosiaMAC "BB:BB:BB:BB:BB:BB";
#
# Globals
#
:global leaseBound
:global leaseServerName
:global leaseActMAC
:global leaseActIP
#
# Script
#
# Insert on Bound
:if ($leaseBound =1) do={
:if ([$leaseActMAC] = $RomekMAC) do={
/tool fetch mode=http url="http://192.168.1.111:8181/json.htm?type=command¶m=switchlight&idx=240&switchcmd=On" dst-path=http_response.txt;
# display the contents of the file with the server's response
:local httpResponse [/file get http_response.txt contents];
:log info "HTTP server response: $httpResponse";
}
:if ([$leaseActMAC] = $GosiaMAC) do={
/tool fetch mode=http url="http://192.168.1.111:8181/json.htm?type=command¶m=switchlight&idx=241&switchcmd=On" dst-path=http_response.txt;
# display the contents of the file with the server's response
:local httpResponse [/file get http_response.txt contents];
:log info "HTTP server response: $httpResponse";
}
}
:if ($leaseBound =0) do={
:if ([$leaseActMAC] = $RomekMAC) do={
/tool fetch mode=http url="http://192.168.1.111:8181/json.htm?type=command¶m=switchlight&idx=240&switchcmd=Off" dst-path=http_response.txt;
# display the contents of the file with the server's response
:local httpResponse [/file get http_response.txt contents];
:log info "HTTP server response: $httpResponse";
}
:if ([$leaseActMAC] = $GosiaMAC) do={
/tool fetch mode=http url="http://192.168.1.111:8181/json.htm?type=command¶m=switchlight&idx=241&switchcmd=Off" dst-path=http_response.txt;
# display the contents of the file with the server's response
:local httpResponse [/file get http_response.txt contents];
:log info "HTTP server response: $httpResponse";
}
}
Users browsing this forum: No registered users and 1 guest