ESP8266 and Switch ?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
4711Austria
Normal user
Posts: 19
Joined: 06 Aug 2021, 12:52

ESP8266 and Switch ?

#1 Post by 4711Austria » 06 Aug 2021, 14:15

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

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESP8266 and Switch ?

#2 Post by Ath » 06 Aug 2021, 14:24

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 ;)
/Ton (PayPal.me)

4711Austria
Normal user
Posts: 19
Joined: 06 Aug 2021, 12:52

Re: ESP8266 and Switch ?

#3 Post by 4711Austria » 06 Aug 2021, 15:07

THX, will do my best.

4711Austria
Normal user
Posts: 19
Joined: 06 Aug 2021, 12:52

Re: ESP8266 and Switch ?

#4 Post by 4711Austria » 06 Aug 2021, 15:39

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.

?

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESP8266 and Switch ?

#5 Post by Ath » 06 Aug 2021, 16:02

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.
/Ton (PayPal.me)

4711Austria
Normal user
Posts: 19
Joined: 06 Aug 2021, 12:52

Re: ESP8266 and Switch ?

#6 Post by 4711Austria » 06 Aug 2021, 16:07

Home Assist (openHub) Mqtt
%sysname%/%tskname%/%valname%

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP8266 and Switch ?

#7 Post by TD-er » 06 Aug 2021, 16:51

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

4711Austria
Normal user
Posts: 19
Joined: 06 Aug 2021, 12:52

Re: ESP8266 and Switch ?

#8 Post by 4711Austria » 06 Aug 2021, 17:02

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.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP8266 and Switch ?

#9 Post by TD-er » 06 Aug 2021, 18:39

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

4711Austria
Normal user
Posts: 19
Joined: 06 Aug 2021, 12:52

Re: ESP8266 and Switch ?

#10 Post by 4711Austria » 07 Aug 2021, 09:03

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....?)
Attachments
Bildschirmfoto 2021-08-07 um 09.03.55.png
Bildschirmfoto 2021-08-07 um 09.03.55.png (92.49 KiB) Viewed 7685 times
Bildschirmfoto 2021-08-07 um 09.00.11.png
Bildschirmfoto 2021-08-07 um 09.00.11.png (184.84 KiB) Viewed 7686 times

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESP8266 and Switch ?

#11 Post by Ath » 07 Aug 2021, 10:42

Can you also show a screenshot of the Switch SW1 settings and the Controller settings (details)?
/Ton (PayPal.me)

4711Austria
Normal user
Posts: 19
Joined: 06 Aug 2021, 12:52

Re: ESP8266 and Switch ?

#12 Post by 4711Austria » 07 Aug 2021, 15:42

here we go
Attachments
screenshot-192.168.0.151-2021.08.07-15_41_34 (1).png
screenshot-192.168.0.151-2021.08.07-15_41_34 (1).png (539.93 KiB) Viewed 7670 times
screenshot-192.168.0.151-2021.08.07-15_41_07.png
screenshot-192.168.0.151-2021.08.07-15_41_07.png (456.89 KiB) Viewed 7670 times

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESP8266 and Switch ?

#13 Post by Ath » 07 Aug 2021, 16:22

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
/Ton (PayPal.me)

4711Austria
Normal user
Posts: 19
Joined: 06 Aug 2021, 12:52

Re: ESP8266 and Switch ?

#14 Post by 4711Austria » 08 Aug 2021, 07:31

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?

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: ESP8266 and Switch ?

#15 Post by Ath » 08 Aug 2021, 10:14

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...).
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests