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

Mqtt user e password #4

Open
wifi75 opened this issue Jul 26, 2022 · 6 comments
Open

Mqtt user e password #4

wifi75 opened this issue Jul 26, 2022 · 6 comments

Comments

@wifi75
Copy link

wifi75 commented Jul 26, 2022

Hello How I can set user end password line in configuration file?

@kristoficko
Copy link

In the script file, before client.connect, specify your user and password:
client.username_pw_set("user", "password")

@wifi75
Copy link
Author

wifi75 commented Jul 28, 2022

In the script file, before client.connect, specify your user and password: client.username_pw_set("user", "password")

Hello I looked at ospiLCD-mqtt.py file but there is no client.connect entry

@kristoficko
Copy link

Look at the script here on GitHub: line 257

@wifi75
Copy link
Author

wifi75 commented Jul 28, 2022

Look at the script here on GitHub: line 257

like this ?

=== Setup MQTT client, actions ===

client = mqtt.Client()
client.on_connect = mqtt_connect
client.on_message = mqtt_message
client.connect(mqttAddress, mqttPort, 60)
client.username_pw_set("user", "password")
client.loop_forever()

and then ??

Set MQTT info (defaults to localhost, if MQTT server is running on Pi)

mqttAddress = "127.0.0.1"
mqttPort = "1883"
user = "myuser"
password = "password"

@kristoficko
Copy link

kristoficko commented Jul 28, 2022 via email

@wifi75
Copy link
Author

wifi75 commented Jul 28, 2022

ok like this:

# === Setup MQTT client, actions ===
client = mqtt.Client()  
client.on_connect = mqtt_connect  
client.on_message = mqtt_message  
client.username_pw_set("user", "password")
client.connect(mqttAddress, mqttPort, 60)
client.loop_forever()

but also this is ocrrect?

mqttAddress = "127.0.0.1"
mqttPort = "1883"
user = "myuser"
password = "password"

I tried like this but after running the scrip it gives me an error:

root@opensprinkler:/home/pi# ./ospiLCD-mqtt.py
Traceback (most recent call last):
  File "./ospiLCD-mqtt.py", line 231, in <module>
    dotsize=8, charmap='A02', auto_linebreaks=True, backlight_enabled=True)
  File "/usr/local/lib/python2.7/dist-packages/RPLCD/i2c.py", line 168, in __init__
    auto_linebreaks=auto_linebreaks)
  File "/usr/local/lib/python2.7/dist-packages/RPLCD/lcd.py", line 98, in __init__
    self._init_connection()
  File "/usr/local/lib/python2.7/dist-packages/RPLCD/i2c.py", line 173, in _init_connection
    self.bus = SMBus(self._port)
IOError: [Errno 2] No such file or directory

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

No branches or pull requests

2 participants