Page 1 of 1

ESP8266 and Switch ?

Posted: 06 Aug 2021, 14:15
by 4711Austria
Hello!

Would like to ask what the settings for a switch are?
Switch on ESP8266 a closed to Gnd, means vom Pin to switch to Gnd, correct?
Possible to send (Mqtt) the opposit, ON = OFF vice versa ?

THX

Re: ESP8266 and Switch ?

Posted: 06 Aug 2021, 14:24
by Ath
Please check out the documentation for Switch, the blue (i) button at the top of the Device Configuration screen: https://espeasy.readthedocs.io/en/lates ... /P001.html and https://espeasy.readthedocs.io/en/lates ... witch-page
You'll want to enable the 'Inversed Logic' checkbox for that ;)

Re: ESP8266 and Switch ?

Posted: 06 Aug 2021, 15:07
by 4711Austria
THX, will do my best.

Re: ESP8266 and Switch ?

Posted: 06 Aug 2021, 15:39
by 4711Austria
Ath wrote: 06 Aug 2021, 14:24 ;)
OK, Switch on D7, intern. Pullup, inversed Logic
works perfect

but the State is not sent via Mqtt ?
on D1/2 there is a SHT31, all values are sent and shown in ioBroker
Controller 1 is active and the switch is checked to send.

?

Re: ESP8266 and Switch ?

Posted: 06 Aug 2021, 16:02
by Ath
What controller are you using?
For Domoticz (both HTTP and MQTT) the IDX needs to be set, for other controllers, the Controller Publish field should contain %tskname% and %valname% to send unique topics to the MQTT controller.

Re: ESP8266 and Switch ?

Posted: 06 Aug 2021, 16:07
by 4711Austria
Home Assist (openHub) Mqtt
%sysname%/%tskname%/%valname%

Re: ESP8266 and Switch ?

Posted: 06 Aug 2021, 16:51
by TD-er
It is good practice not to short a pin directly to Vcc or GND, but rather use some resistor to pull the logic level "up" or "down".

For example what if the pin is pulled down or up in the software, but it is shorted to Vcc or GND.
Then the GPIO may have a higher current flowing than allowed.

Another thing to keep in mind is that you must have some pins in a very specific state during boot.
See: https://espeasy.readthedocs.io/en/lates ... on-esp8266

Re: ESP8266 and Switch ?

Posted: 06 Aug 2021, 17:02
by 4711Austria
I know, but works fine.

What I need is the info sent via Mqtt, actually nothing is getting out from the State of the Switch.

Re: ESP8266 and Switch ?

Posted: 06 Aug 2021, 18:39
by TD-er
Do you have a switch task, which can send the state to a connected controller?
Another option is to activate monitoring of a specific pin using the "monitor" command in the rules.
This will generate an event when the pin state changes and this can be used in the rules to trigger some action, like sending a message to the MQTT broker via the "publish" command.

Some docs links:
https://espeasy.readthedocs.io/en/lates ... tem-events
https://espeasy.readthedocs.io/en/lates ... r#commands

Re: ESP8266 and Switch ?

Posted: 07 Aug 2021, 09:03
by 4711Austria
Switch is set as Device
Home Assist for Mqtt connection to ioBroker (Adapter Sonnos)
only the SHT31 is sent to ioBroker.

(are inputs and outputs to sent via Wifi not the Basic function....?)

Re: ESP8266 and Switch ?

Posted: 07 Aug 2021, 10:42
by Ath
Can you also show a screenshot of the Switch SW1 settings and the Controller settings (details)?

Re: ESP8266 and Switch ?

Posted: 07 Aug 2021, 15:42
by 4711Austria
here we go

Re: ESP8266 and Switch ?

Posted: 07 Aug 2021, 16:22
by Ath
Ok, that looks nearly standard. Can't see anything really strange yet...

I'm a bit puzzled by port 1886 on the MQTT broker, the usual default for that is 1883

Re: ESP8266 and Switch ?

Posted: 08 Aug 2021, 07:31
by 4711Austria
1883 is already in use, so I took an other number, should not be the problem

Is it possible to analyse the Mqtt, maybe the Status is transferred and ioBroker does not show it?

Re: ESP8266 and Switch ?

Posted: 08 Aug 2021, 10:14
by Ath
There are GUI-tools available for most OS's to monitor the MQTT message flow, there you could just subscribe to # or your esp %sysname%/# to see all messages. Be aware that MQTT is case-sensitive (and ESPEasy is not, except in MQTT topics...).