I have a Wemos D1 (ESP8266) which does not have much i/o, so i added a PCF8574 i/o expander.
This needs to be connected to Domiticz via MQTT (mosquitto).
(Eventually there will be 4 buttons and 4 leds, oled and relay connected to this, if the amount of tasks allow it.
There will be more devices like this controlling the same switches and temperatures in Domoticz, that's why i am trying to use mqtt to set this up, to avoid having to send multiple http commands from each device to keep the rest updated.)
What i have now as a test setup:
For one pushbutton/led combo, i use two tasks:
1. A pushbutton connected to port 1 on the PCF8574, this can only be configured as normal switch in espeasy.
2. A led connected to port 2 of the PCF8574 to indicate visually and to use as status for linking to Domoticz (since the pushbutton cannot do this on the PCF).
To switch the status using the pushbutton, i made this script:
Code: Select all
// Knop1
on PCF1Button1#State=1 do // Pushbutton pressed
if [PCF1Led2#State]=0 //If led is off then
PCFGPIO,2,0 // Switch on led (inversed logic)
else
PCFGPIO,2,1 // Else switch off led (inversed logic)
endif
endon
I press the pushbutton, PCF1Poort1 becomes 0, the event is triggered and it changes the state of PCF1Led2, then i release the button and PCF1Poort1 becomes 1 again. The led does not change state until i press the button again. This is ok.
This ESP is linked to "Domoticz MQTT" and i added/linked the IDX (idx = 14) to PCF1Led2 on the device/task page of PCF1Led2. This is updated nicely in Domoticz when i press the pushbutton.
But when i click the switch in Domoticz, the led on the ESP is not responding.
I tried finding a solution to this, but the info is a bit confusing, maybe due to older versions used in the info i found.
Do i need to sacrifice a task for a "Generic - MQTT Import" device? I tried linking it to the Domoticz/out/$14 but it does not respond.
Then i figured it might be the other way around and i had to use the "Output - Domoticz MQTT Helper" device, but this can only be linked to general GPIO devices, which i cannot use because there are not enough of them.
Is there any way to make this work?
Also, how would i import temperature sensors from domoticz mqtt into this esp?
Firmware: 20113 - Mega