Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudMQTT and Direct Operation #2

Open
matheustms opened this issue Nov 23, 2016 · 11 comments
Open

CloudMQTT and Direct Operation #2

matheustms opened this issue Nov 23, 2016 · 11 comments

Comments

@matheustms
Copy link

I don't want to use CloudMQTT and I dont know what I need to change to set my raspberry ip as local broker. When I'm setting up the wifi credentials, the space for ip broker are defined as CloudMQTT and I can't change it.

Another problem is when I reset the Sonoff, I can't do direct relay operation through on board button without setting up the wifi credentials first. Thats bad because I cant operate the sonoff if I don't have wireless in home, at least for instance.

If I'm saying shit, sorry for my ignorance on this theme.

@SamZorSec
Copy link
Owner

Hi,
Thank you for your feedback.

  • If you want to use your local MQTT broker without TLS (and CloudMQTT), you just need to comment #define TLS (line 65).
  • If you want to use your local MQTT broker with TLS, you need to change the line 359:
  WiFiManagerParameter custom_mqtt_server("mqtt-server", "MQTT Broker IP", "m21.cloudmqtt.com", STRUCT_CHAR_ARRAY_SIZE, "disabled");

with your broker's IP address

  WiFiManagerParameter custom_mqtt_server("mqtt-server", "MQTT Broker IP", "<YOUR BROKER ADDRESS>", STRUCT_CHAR_ARRAY_SIZE, "disabled");

and the lines 67 and 71, with the CN and the fingerprint of your broker's certificate:

// TLS support, make sure to edit the fingerprint and the broker address if
// you are not using CloudMQTT
#define           TLS
#ifdef TLS
const char*       broker      = "m21.cloudmqtt.com"; 

// SHA1 fingerprint of the certificate
// openssl x509 -fingerprint -in  <certificate>.crt
const char*       fingerprint = "A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07";
#endif

I'll modify the sketch to work without an active Wi-Fi connection.

Sam

@matheustms
Copy link
Author

Thank you so much, bro.

If not too much to ask, can you implement the input settings of MQTT topics too when we are setting up the network and entering the MQTT username, password, broker IP address and broker port. So we can setup everything on the web configuration portal.

Another question is when I long press the button, reset the relay or all the configurations to default?

Thanks so much again

@matheustms
Copy link
Author

Find another problem (rsrs), there is no auto reconnect function. When I turn restart my router and not restart sonoff, it calls the wifi manager again, to set another wireless credentials.

@SamZorSec
Copy link
Owner

If not too much to ask, can you implement the input settings of MQTT topics too when we are setting up the network and entering the MQTT username, password, broker IP address and broker port. So we can setup everything on the web configuration portal.

Implemented now.

Another question is when I long press the button, reset the relay or all the configurations to default?

6-7 seconds. If the LED doesn't blink, unplug/plug the Sonoff from power.

Find another problem (rsrs), there is no auto reconnect function. When I turn restart my router and not restart sonoff, it calls the wifi manager again, to set another wireless credentials.

The module will restart now if no IP address is assigned to it. It's not easy to test if the module is connected to the internet. My Wi-Fi is always on.

void reconnect() {
  // test if the module has an IP address
  // if not, restart the module
  if (WiFi.status() != WL_CONNECTED) {
    DEBUG_PRINTLN(F("ERROR: The module isn't connected to the internet"));
    restart();
  }
  ...

@matheustms
Copy link
Author

Man, you are the best. Really, the best. I will try when I get home. I don't know how to implement functions because I'm new on this. Thanks for help me. If I found another thing, I will tell you for sure. Rsrs

@matheustms
Copy link
Author

Did you did this "I'll modify the sketch to work without an active Wi-Fi connection."?

@SamZorSec
Copy link
Owner

Did you did this "I'll modify the sketch to work without an active Wi-Fi connection."?

Not yet. It's complicated because I use the WiFiManager library and if the connection to the router isn't successful, the module restarts. I control it only with MQTT and Home Assistant and I'll probably not implement this feature.

Alternative firmwares:

@matheustms
Copy link
Author

I understand. I use MQTT and Home Assistant too, but I need to implement this because if my router gets dead, for example, I can't ativate the relay and my house will stay in dark, if it's night. I use sonoff as my light switch. I will study on this, I really like your firmware. Thanks Man.

@kornfool
Copy link

newbies here, how to get the fingerprint ?

@SamZorSec
Copy link
Owner

if you have the public certificate, just use the following command :

// SHA1 fingerprint of the certificate
// openssl x509 -fingerprint -in  <certificate>.crt

https://knowledge.symantec.com/support/identity-protection-support/index?page=content&id=SO28771&actp=RSS&viewlocale=en_US
or
https://www.grc.com/fingerprints.htm

@Sunrise17
Copy link

How to assign different Fingerprints for each sonoff (with tasmota fw) device to connect CloudMqtt? For secure connection, each device has a particular Fingerprint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants