Hello,
I ask to AI ( chat.openai) to make a scrip in dzvents to detect an device connected to the network (based on MAC) and signaling in domoticz with an ON/OFF switch.
what information did I give him:
all devices are on the same network. Some by cable, others wi-fi.
I gave him the idx of the button and the name of the button in domoticz.
I told him how to signal the connected device (with ON/OFF switch)
it returned me the script below but it doesn't work.
I have no error in Domoticz LOG
I use domoticz 2002.2 instaled on raspberry 4
return {
on = {
timer = {
'every minute'
}
},
execute = function(domoticz, device)
-- Specify the MAC address of the device
local macAddress = 'ac:00:03:85:00:00'
--Specify the IDX of the virtual button
local deviceIdx = 133
-- It executes the arp command and saves the result in a variable
local handle = io.popen('arp -a -n | grep -i ' .. macAddress .. ' | wc -l')
local result = handle:read("*a")
handle:close()
-- Check if the value is 1 or 0
if (tonumber(result) == 1) then
-- The value is 1, the device is connected
domoticz.devices(deviceIdx).switchOn().silent()
else
-- Vallo is not 1, the device is not connected
domoticz.devices(deviceIdx).switchOff().silent()
end
end
}
I check the arp comand, whit some MAC and i get the corect result. 1 or 0, depending on the MAC.
MAC detect in the same network
Moderator: leecollings
-
ssk17051980
- Posts: 112
- Joined: Thursday 08 December 2022 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: ROMANIA
- Contact:
-
mgugu
- Posts: 226
- Joined: Friday 04 November 2016 12:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: France
- Contact:
Re: MAC detect in the same network
Maybe the ARP table is not updated with that MAC. You can try to issue a ping command before. With IP if you know it or broadcast address if not.
- waltervl
- Posts: 6691
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: MAC detect in the same network
Do not trust AI ( chat.openai) and read trhe dzVents documentation.
Especially the part where it describes the running of os commands (like arp): https://www.domoticz.com/wiki/DzVents:_ ... _execution
Especially the part where it describes the running of os commands (like arp): https://www.domoticz.com/wiki/DzVents:_ ... _execution
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
ssk17051980
- Posts: 112
- Joined: Thursday 08 December 2022 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: ROMANIA
- Contact:
Re: MAC detect in the same network
my knowledge in programming, etc. is below sea level. I can't do it alone
- waltervl
- Posts: 6691
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: MAC detect in the same network
You can use the ping function of Domoticz to check if devices are live. You have to get the devices a fixed IP by your router.
https://www.domoticz.com/wiki/System_Al ... ker_(Ping)
Else search for presence detection domoticz for some other plugins and functions.
https://www.domoticz.com/wiki/System_Al ... ker_(Ping)
Else search for presence detection domoticz for some other plugins and functions.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
ssk17051980
- Posts: 112
- Joined: Thursday 08 December 2022 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: ROMANIA
- Contact:
Re: MAC detect in the same network
I solved it with the PING function. Thanks, I prefer MAC because it's about mobile phones and sometimes the router makes mistakes and doesn't reserve their IP. I found a script for domoticz iDetect, but it gives me errors during installation and I was not able to complete the process
Who is online
Users browsing this forum: No registered users and 1 guest