lxnoid / SomfyIO

1 stars 2 forks source link

Cannot find the esp on MQTT #4

Open djacid opened 8 months ago

djacid commented 8 months ago

Hello, I have some issues. I can compile without any issues the project and upload it on my esp.

The problem is I can't find the device to MQTT server. The logs also don't show any information. Could you please help me? How can I control the remote? Is there any web interface or only via MQTT?

lxnoid commented 8 months ago

Sure,

do you have the full logs when the esp connects? Screenshot would also be fine. What mqtt tool do you use?

djacid commented 8 months ago

Thank you for your fast response. First of all I used a wemos d1 mini v3 (ESP8266), so I edited my env to this:

[env:d1_mini] platform = espressif8266

platform = espressif32

framework = arduino lib_deps = knolleary/PubSubClient@^2.8 nickgammon/Regexp@^0.1.0 smfsw/Queue@^1.9.1 bblanchon/ArduinoJson@^6.17.3

board = d1_mini_lite

board = nodemcu-32s

board = d1_mini_pro

board = d1_mini board_build.filesystem = littlefs build_flags = -DDEBUG_ESP_PORT=Serial monitor_speed = 115200

My config.json file is this:

{ "wifiSsid" : "WifiHomeNetwork",
"wifiPassword" : "wifipass", "mqttServer" : "192.168.1.179", "mqttPort" : "1883", "mqttUser" : "admin", "mqttPassword" : "mqttpass", "mqttClientID" : "somfyIO" }

I use mqtt explorer for testing and Home Assistant for my house.

I edited main.ccp file and changed the pinout ports to these:

define PIN_CH1 D3 // 200Hz pulses while all channels lit, low active while channel 1 selected

define PIN_CH D0

define PIN_UP D2

define PIN_MY D5

define PIN_DWN D1

The logs after build are these:

Processing d1_mini (platform: espressif8266; framework: arduino; board: d1_mini)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html PLATFORM: Espressif 8266 (4.2.1) > WeMos D1 R2 and mini HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash PACKAGES:

The logs after upload are these:

Processing d1_mini (platform: espressif8266; framework: arduino; board: d1_mini)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html PLATFORM: Espressif 8266 (4.2.1) > WeMos D1 R2 and mini HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash PACKAGES:

Leaving... Hard resetting via RTS pin... ===================================== [SUCCESS] Took 27.11 seconds =====================================

And the logs of serial monitor are only these:

Executing task: platformio device monitor --environment d1_mini --port /dev/cu.usbserial-14320

--- Terminal on /dev/cu.usbserial-14320 | 115200 8-N-1 --- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time --- More details at https://bit.ly/pio-monitor-filters --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H

lxnoid commented 8 months ago

I may ask if the filesystem was also build and uploaded? Can you try the latest commit? Added more output for the phases.

image

djacid commented 8 months ago

Processing d1_mini (platform: espressif8266; framework: arduino; board: d1_mini)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html PLATFORM: Espressif 8266 (4.2.1) > WeMos D1 R2 and mini HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash PACKAGES:

lxnoid commented 8 months ago

I assume/think the upload did not work as the device was not reset/in boot mode - currently I have no spare d1 mini, yet could you try to reset/connect the d1 mini shortly before upload/flashing?

djacid commented 8 months ago

I tried again and now I got this:

Processing d1_mini (platform: espressif8266; framework: arduino; board: d1_mini)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html PLATFORM: Espressif 8266 (4.2.1) > WeMos D1 R2 and mini HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash PACKAGES:

Leaving... Hard resetting via RTS pin... ====================================== [SUCCESS] Took 6.29 seconds ======================================

D1 Mini also now blinks blue led repeatedly

djacid commented 8 months ago

But the device is not connected to Wifi

djacid commented 8 months ago

Debugging return this: [{ "resource": "/Users/anastasioschatziliadis/Downloads/SomfyIO-master 2/.pio/libdeps/d1_mini/PubSubClient/src/PubSubClient.cpp", "owner": "cpp", "severity": 4, "message": "comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]", "startLineNumber": 523, "startColumn": 16, "endLineNumber": 523, "endColumn": 16 }]

lxnoid commented 8 months ago

Then try to upload the application and monitor it, then post the output.

djacid commented 8 months ago
Screenshot 2024-03-10 at 10 57 10 PM
lxnoid commented 8 months ago

The terminal output is complete?

djacid commented 8 months ago

No it was huge, but there is progress. I removed all the special characters from mqtt password. Not, the device connected succesfully to Wifi. I will try again to place the correct mqtt password

djacid commented 8 months ago

If I change the password of MQTT I have the error. The Password is something like PasswordPhrase2@1! Do you believe that there is issue with these special characters?

lxnoid commented 8 months ago

Awesome, based on the number of issues with the json parsing, I should find another solution to store the config aside the code.

lxnoid commented 8 months ago

If I change the password of MQTT I have the error. The Password is something like PasswordPhrase2@1! Do you believe that there is issue with these special characters?

Maybe - easiest way is to place the password in the code at the assignments to the variables.

lxnoid commented 8 months ago

const char *c_mqttPassword = ”test@!”;

like this

djacid commented 8 months ago

Yes! It seems finally working. I can see the device on MQTT as "shades/terrace"

lxnoid commented 8 months ago

Then some parsing of the json file is the issue. Which encoding is your file?

djacid commented 8 months ago

How can I see the encoding?

djacid commented 8 months ago

About MQTT, I can see only these.

Screenshot 2024-03-10 at 11 20 59 PM
lxnoid commented 8 months ago

How can I see the encoding?

https://code.visualstudio.com/docs/editor/codebasics#:~:text=Set%20the%20file%20encoding%20globally,Then%20choose%20an%20encoding.

@djacid mqtt looks fine

djacid commented 8 months ago
Screenshot 2024-03-10 at 11 33 52 PM

About MQTT, unfortunately Home Assistant cannot find any topics, because Home Assistant needs a prefix.

Screenshot 2024-03-10 at 11 35 22 PM
djacid commented 8 months ago

Also I really don't understand what's the mqtt command to change channel for instance

Edit: I found the way to change channel. But I don't know what's the command to simulate a button press

lxnoid commented 8 months ago

here is the cover-part of my mqtt section of the configuration.yaml of HA: ` cover:

So just to explain the concept: the ESP will autodetect channel1 on bootup with the help of the interrupt routine and the led feedback. Then whenever a command is sent from HA (or other sources) the ESP will select the channel based on current known selection, then switch to the new channel if needed and perform the button press.

djacid commented 8 months ago

Perfect, ok I understood. One more question about the state of last command. Does last command state updates only after mqtt command or it's able to update also after physical button press?

lxnoid commented 8 months ago

As I have 3D-printed a pogo-pin-Adapter with a housing, for me there is no physical interface anymore. Based on the current design, it would not. This would need to monitor the buttons in parallel, and also check the channel selection.

image

To increase the WAF, there is a zigbee-MQTT switch with choices for the shades next to the patio door, so I don't need to have the phone/smartspeaker nearby all the time.

djacid commented 8 months ago

As I am still trying to fix some thing, could you please tell me if it's the normal behaviour to change the channel (increasing by one) if you run the same command repeatedly. To be more specific, if I run cmd/channel1, the remote controls goes to channel1, but if I run the same command again, then it moves to channel 2 etc.

lxnoid commented 8 months ago

I haven't observed this one, after looking into the code I'd say that would be unlikely but not completly impossible. Can you check/post the output in that case?

It should remember known and current channel. If it can't detect or switch to the right channel, it will sweep until it finds it.

djacid commented 8 months ago

I will check the output later today and I will post again. If you want to repoduce what I said you have to send for instance the command cmd/channel2 and before the green light of the remote turned off, send again the same command. You will notice that every time you send the command, the channel will be stepping by 1. The only way to stay on the same channel is only if you wait for 5 seconds for the green light to be turned off.

lxnoid commented 8 months ago

Ah, this is some good finding- haven’t tested or tried. But that is indeed something that would not work. I guess I/someone need to block the command during this time. Or something smarter.