Comments (3)
Ok, it seems i have found a solution that suits my needs.
Used url as base for info and made modifications.
samplefuncs.py:
def ecowitt_fields(data, srv=None):
"""Extract fields from JSON payload of messages on topic
ecowitt and publish the fields on separate
MQTT topics ecowitt/[Field]."""
if type(data) == dict and "winddir" in data and "windspeed" in data:
base_topic = "ecowitt"
republish_fields = ['winddir', 'windspeed']
if type(data) == dict and srv is not None:
for field, value in data.items():
if field in republish_fields:
srv.mqttc.publish("/".join([base_topic, field]), value, qos=0, retain=False)
return None
and into mqttwarn.ini i added:
[ecowitt]
targets=log:info
format=ecowitt_fields()
[ecowitt/+]
targets = influxdb:ecowitt
It all seems to work ... maybe there are some simplier solutions but this seems to finally serve the purpose for me.
from mqttwarn.
Good day,
What i wanted was simple - incoming json republished to mqtt as separate topics under one base.
That filtering is there with case "it's possible" but not mandatory.
But as my solution seemed quite hacky i asked maybe it can be solved with existing code ...
But if not i will continue with my solution as it works :)
Regards,
Martin
from mqttwarn.
Hi Martin,
excellent. Thanks for sharing your procedures.
So, effectively you are doing some JSON attribute filtering and MQTT topic rewriting in your custom code, right? I wonder if mqttwarn would offer a corresponding plugin out of the box, at least for the re-publishing part?
In any case, we are happy that you managed to find a solution using mqttwarn with custom code.
With kind regards,
Andreas.
from mqttwarn.
Related Issues (20)
- Remove `gss` service plugin in favor of `gss2`? HOT 3
- mqttwarn 0.34.0 sdist size change HOT 1
- mqttwarn nine years ago HOT 6
- Absorb mqttshark? HOT 5
- Documentation on Image-based installation is wrong HOT 3
- [Nextcloud] Verify thoroughness of implementation over Apprise
- [ntfy] Bug with notification messages longer than 76 characters HOT 5
- Improve ntfy documentation on authorization and/or add authorization header HOT 4
- Docker issue with pushbullet (mqttwarn-full) HOT 8
- [ntfy] Error if message contains newline character `\n` HOT 14
- [pushover] unable to decode base64 encoded image
- Nightly to latest docker build - what is the trigger for this? HOT 5
- Object of type bytes is not JSON serializable HOT 5
- Use `dynamic-imports` for loading Python code at runtime
- Pull effective recipient from message payload HOT 3
- Messages directed only to the first target when a format function is defined HOT 2
- TLS issues with mosquitto-2.0.18 HOT 6
- mqttwarn does not like py39-paho-mqtt-2.0.0 HOT 12
- ntfy title results in ''=?utf-8?q?' prefix? 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 mqttwarn.