Code: Select all
{
"log": "",
"plugin": 9,
"pin": 4,
"mode": "input",
"state": 0
}
Moderators: grovkillen, Stuntteam, TD-er
Code: Select all
{
"log": "",
"plugin": 9,
"pin": 4,
"mode": "input",
"state": 0
}
The "status" command is (also) an ESPEasy core command and doesn't need a device/task to be set up, only connected (but that shouldn't be a problem ), as it directly reads the status via the I2C bus.
Code: Select all
on ... do
endon
Code: Select all
on System#Boot do
Monitor,MCP,<MCPGPIO> // Need to fill in the pin(s) you would like to monitor
endon
on mcp#1 do // Act on MCP pin #1
if %eventvalue1%=0
// pin state low
...
else
// pin state high
...
endif
endon
Code: Select all
On System#Boot Do
MCPModeRange,17,32,1
MonitorRange,MCP,17,32
Endon
Code: Select all
on mcp#1 do // Act on MCP pin #1
if %eventvalue1%=0
// pin state low
...
otherwise
// pin state high
...
endif
endon
Code: Select all
on mcp#1 do // Act on MCP pin #1
SendToUDP,<destination-ip>,<port>,'%sysname%_mcp_1_state=%eventvalue1%'
endon
// Or alternatively for all pins in a single rule:
on mcp do
SendToUDP,<destination-ip>,<port>,'%sysname%_mcp_%eventpar%_state=%eventvalue1%'
endon
Code: Select all
on mcp do
Code: Select all
on mcp#26 do
Code: Select all
on mcp* do
SendToUDP,<destination-ip>,<port>,'%sysname%_mcp_%eventpar%_state=%eventvalue1%'
endon
Code: Select all
on mcp* do
If [mcp*#eventvalue1]=1 Do
SendToUDP,192.168.1.100,5555,'%sysname%_mcp_%eventpar%_state=0'
Endif
If [mcp*#eventvalue1]=0 Do
SendToUDP,192.168.1.100,5555,'%sysname%_mcp_%eventpar%_state=1'
Endif
endon
Could be as simple as this: (eventvalueX must be wrapped with % signs)Smotek7 wrote: ↑10 Sep 2024, 15:37Code: Select all
on mcp* do If [mcp*#eventvalue1]=1 Do SendToUDP,192.168.1.100,5555,'%sysname%_mcp_%eventpar%_state=0' Endif If [mcp*#eventvalue1]=0 Do SendToUDP,192.168.1.100,5555,'%sysname%_mcp_%eventpar%_state=1' Endif endon
Code: Select all
on mcp* do
SendToUDP,192.168.1.100,5555,'%sysname%_mcp_%eventpar%_state=!%eventvalue1%'
endon
Code: Select all
on mcp* do
let,1,!%eventvalue1%
SendToUDP,192.168.1.100,5555,'%sysname%_mcp_%eventpar%_state=%v1%'
endon
Code: Select all
on mcp* do
Let,1,!%eventvalue1%
SendToUDP,192.168.1.100,5555,'%sysname%_mcp_%eventpar%_state=%v1%'
endon
Code: Select all
gpio,1,=!%eventvalue1%
Code: Select all
on mcp* do
Let,1,!%eventvalue1%
TaskValueSet,1,1,%eventpar%
TaskValueSet,1,2,%v1%
endon
Code: Select all
TaskValueSetAndRun,1,1,%eventpar%*10+%v1%
2 things are probably mixed up here:
Users browsing this forum: Semrush [Bot] and 1 guest