Comments (4)
Oh, okay, I wasn't aware that I could access the value field like that.
Kind of guilty of not reading the docs and relying on Intellisense π
.
Great work with this library, it's really useful, and thanks for the pleasant response!
from aiomqtt.
Hi there! π It's not entirely clear to me from your description why your code was not working, or what changes you are suggesting. Could you post a minimal working example?
from aiomqtt.
This is the code I was using:
if message.topic == "/app/device/property/DAEBZ5KEB033484":
await sio.emit('delta', message.payload)
elif message.topic == "/app/device/property/R601ZEB5HF260973":
await sio.emit('river', message.payload)
and it wasn't working, the condition was never true, so I changed the ==
to message.topic.matches()
, like this
if message.topic.matches("/app/device/property/DAEBZ5KEB033484"):
await sio.emit('delta', message.payload)
elif message.topic.matches("/app/device/property/R601ZEB5HF260973"):
await sio.emit('river', message.payload)
My suggestion is for ==
to do the same as .matches()
, if no other case requieres the ==
comparation to be what it is now
from aiomqtt.
Thanks for the example! π
Topic.matches()
can match filters as well, so something like Topic("a/b/c").matches("a/+/c")
returns true, as shown in the Filtering messages section in our docs. If you want, you can access the topic string directly via Topic.value
.
Replacing Topic.matches()
entirely by ==
(by implementing __eq__
for Topic
) would lead to something unexpected, namely that Topic("a/b/c") == "a/+/c"
would return true and "a/+/c" == Topic("a/b/c")
would return false.
Does that make sense? π
from aiomqtt.
Related Issues (20)
- Impossible to reuse client in case of connection timeout HOT 7
- Typing warnings in IDE on Client methods HOT 2
- AttributeError: module 'aiomqtt' has no attribute '__version__'
- session persistence with protocol version 5 HOT 1
- Pin Paho to <2.0 HOT 2
- Make aiomqtt compatible with paho v2 HOT 10
- How to get the IP of a failed connection attempt
- strange reconnection HOT 2
- MQTT broker reports a disconnection/reconnection... but no aiomqtt.MqttError is raised HOT 4
- Exceptions on __aenter__ not handled. HOT 2
- Reconnect Bug HOT 1
- Cannot instantiate a client due to internal mqtt problem HOT 2
- Issues with uvicorn on Windows 10 HOT 5
- [BUG] Cannot install version 2.0.0 with paho-mqtt 2.0.0 HOT 2
- [BUG] 127.0.0.1/localhost Work Incorrectly HOT 3
- Do not send messages for a long time mqtt automatically disconnects HOT 2
- Can't read incoming messages in pytests HOT 8
- No convenient way to get message without getting locked into a for loop HOT 2
- Can aiomqtt queue has a ring buffer optionοΌ for high frequense in-comming messages? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiomqtt.