I'm running ESP Easy on a Wemos D1 mini Pro, connected through MQTT to OpenHAB, and with 2 MCP23017's hooked up through I²C. I can control the inputs and outputs of the MCP's just fine from OpenHAB, so I know my hardware is working.
I am trying to set up a local Rule to trigger on mcp#17 (=MCP 0x21 PA0) and toggle the state of output mcpgpio,1 (=MCP 0x20 PA0) . This is my code:
Code: Select all
on System#Boot do
Monitor MCPGPIO,17 // monitor pin for state changes
endon
on mcp#17 do
Publish,%sysname%/Debug/OnMcp17,"on mcp#17 triggered" //debug message 1
Publish,%sysname%/Debug/OnMcp17,[plugin#mcpgpio#pinstate#1] //debug message 2
if [plugin#mcpgpio#pinstate#1]=1 //LED is off
Publish,%sysname%/Debug/IfPinState,"[plugin#mcpgpio#pinstate#1] triggered 1" //debug message 3
mcpgpio,1,0 // set LED on
endif
if [plugin#mcpgpio#pinstate#1]=0 //LED is on
Publish,%sysname%/Debug/IfPinState,"[plugin#mcpgpio#pinstate#1] triggered 2" //debug message 4
mcpgpio,1,1 // set LED off
endif
endon
The value of [plugin#mcpgpio#pinstate#1] in debug message 2 is "" , which resolves to some UTF or ASCII encoding for "SOH"... I don"t understand this result. Shouldn't [plugin#mcpgpio#pinstate#1] return a 0 or 1 depending on the pin state low or high?
If not, how can I test if my MCP output pin is high or low so I can toggle it?
Running build ESP_Easy_mega_20211105_normal_beta_ESP8266_16M_LittleFS Nov 5 2021
Thanks in advance!
- John