mosquitto_sub and Tuya TS0601 TRV - mqtt

Is it possible to send settings to a TS0601 TRV from MQTT?
For example:
# mosquitto_pub -h localhost -t Home/Bed3/Radiator/set/force -m "open" -d
Client mosqpub|19143-mini31 sending CONNECT
Client mosqpub|19143-mini31 received CONNACK (0)
Client mosqpub|19143-mini31 sending PUBLISH (d0, q0, r0, m1, 'Home/Bed3/Radiator/set/force', ... (4 bytes))
Client mosqpub|19143-mini31 sending DISCONNECT
but nothing happens.
I can see my sent messages appearing in
# mosquitto_sub -h localhost -t Home/Bed3/Radiator/# -v

Related

MQTT bridge not authorised while using correct subscriber params

I can successfully subscribe to my MQTT broker:
mosquitto_sub -h myremotehost -p 8883 --cafile mqtt_ca.crt -u username --pw userpasswd -t mytopic/#
But I got error Connection Refused: not authorised when I try to run MQTT bridge configured with same params in my config file:
connection conn1
address myremotehost:8883
bridge_cafile mqtt_ca.crt
remote_username username
remote_password userpasswd
topic mytopic/# both
Any suggestions what to look for?
EDIT:
Log entry on original broker that bridge can not connect to:
1580391693: OpenSSL Error: error:14094412:SSL routines:SSL3_READ_BYTES:sslv3 alert bad certificate
1580391693: OpenSSL Error: error:140940E5:SSL routines:SSL3_READ_BYTES:ssl handshake failure
It says bad certificate, but as I mentioned above, it's the same cert file I use while successfully subscribing from client

how to properly pass certificates to both mosquitto_pub and mosquitto_sub in order to have a TLS communication?

I have this setup
in Remote server. I tried
mosquitto_sub -h 127.0.0.1 -t 'myTopic' -i 'myId'
in My computer I tried
mosquitto_pub -h 'remote_ip_here' -t 'myTopic' -m 'the message'
the remote server was able to get the message I published from my computer
the remote server has these keys
certificate file = cert.pem
certificate key file = privkey.pem
certification chain file = chain.pem
If I want to have a ssl/tls communication between my computer and the remote computer.
- How do I use those keys ?
- Am I suppose to copy those keys from the remote computer and put them also in my computer ?
- can someone please help what's the proper command to execute in order to have an ssl and tls communication.
In the remote server I tried
mosquitto_sub -h 127.0.0.1 -t 'myTopic' -i 'myId' --capath /etc/myPemPath -p 1883
While in my computer, I tried
mosquitto_pub -h remote_ip -t 'myTopic' -m 'the message' --capath /etc/localPemPath -p 1883
it didn't work, so how ?
You seem to have miss understood how MQTT works. Both mosquitto_sub and mosquitto_pub are MQTT clients which communicate with a MQTT broker (mosquitto). It is not a direct client/server relationship.
In order to have TLS secured MQTT connection you first need to configure the broker to use the certificates to identify it's self, then configure the clients to verify that certificate as part of the TLS handshake.
The mosquitto documentation on how to configure TLS is available here. You need to add either a cafile or capath and certfile and keyfile options to your mosquitto.conf file. Be aware that TLS settings apply to the last listener configured, so you will probably need to set up a new listener on a different port to 1883.
As for the clients, assuming you are not doing mutual authenticated TLS then you only need to pass the -cafile/-capath option to mosquitto_pub and mosquitto_sub to enable a TLS session.

Mosquitto client can't publish message to EMQ X Broker

I have model like this:
EMQ X Broker installed at IP 222.x.y.z.
And two Mosquitto client.
I want to publish message from Mosquitto_client_2 then receive Mosquitto_client_1.
I do like this:
Step 1: run command:
mosquitto_sub -h 222.x.y.z -t "TEST_TEST"
on Client_1
Step 2: EMQ X Broker auto create topic "TEST_TEST", like this
Step 3: Mosquitto client 2 publish message, run command:
mosquitto_pub -h 222.x.y.z -t TEST_TEST -m "hello world"
But it have problem "Error: Connection refused" like this:
I don't know the cause of the error and how to fix this error.
P/s: I also open all port for EMQ X.
You should first eliminate the network problem and use telnet to determine whether the port can be accessed.
telnet localhost 1883
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Subscribing to Amazon aws iot mqtt

I'm trying to subscribe to mqtt broker in aws.
For subscribing i'm using mosquitto client (Ver 1.4.11).
Command goes like this
mosquitto_sub.exe --cafile "path_to_ca" --cert "path_to_cert" --key "path_to_key" -h id1234.iot.ap-northeast-1.amazonaws.com -p 8883 -q 1 -d -t '$aws/things/DeviceTokyo/shadow/get' -i DeviceTokyoCMD
But I'm getting the following response
Client DeviceTokyoCMD sending CONNECT
Error: The connection was lost.
I figured the issue.There was something wrong with the policy resource ARN. So I made the change allowing to accept it from anywhere as *

Mosquitto not working over TLS on Raspberry Pi

I have installed Mosquitto on a brand new Raspberry Pi. OS is Raspbian.
I followed the instructions on the Owntracks website.
The broker is listening on port 1883 on localhost. Using a username and password I can run mosquitto_sub in one ssh session to the Pi, and receive messages sent by mosquitto_pub from another ssh session.
The broker is also listening on port 8883. I created certificates using the script in the Owntracks repository.
When I run mosquitto_pub on the Pi, using the hostname or IP-address I get an error "Error: Connection refused".
When I use localhost or 127.0.0.1 the error is "A TLS error occurred.".
If I run mosquitto_pub on my desktop computer (which is in the same LAN as the Pi), the error is "Connection refused". The command I run here is
mosquitto_pub -t owntracks/test -m Test -h pi1 --cafile ca.crt
where pi1 is the hostname of the Pi running the broker. The ca.crt file is copied from the Pi to the desktop computer.
The Mosquitto log is not showing why the connections are refused.
The TLS setup in the Mosquitto config looks like this:
listener 1883 127.0.0.1
listener 8883
cafile /etc/mosquitto/ca_certificates/ca.crt
certfile /etc/mosquitto/certs/server.crt
keyfile /etc/mosquitto/certs/server.key
require_certificate false
What is wrong in my setup?
if you try to use TLS with mosquitto
you must add this option to your command "-p 8883" to indicate the port
and you don't need to put "-h localhost or pi " because you use the client command mosquitto_pub in the same machine that run mosquitto broker
then your command we'll be :
"mosquitto_pub -d -u username -P password -t /path/to/the/topic --cafile /path/to/the/certificate -p 8883
don't forgot to comment this line
listener 1883
in your mosquitto.conf
Recreating all certificates solved the problem. Apparently I did something wrong with including local vs. remote IP-addresses and host names.
The TLS error messages are not very informative, but that probably has to do with security precautions.

Resources