ottopaulsen / MMM-MQTT

MQTT Client module for MagicMirror2
MIT License
57 stars 29 forks source link

Feature expansion: Conversions accept range #61

Closed Schalmeier closed 1 year ago

Schalmeier commented 1 year ago

Code Written by ChatGPT (as im no Java guy) The Conversion function accepts values with a "-" and handles the two values besides it as range. (I need to convert wind direction degrees into N, NE, ....) conversions: [ { from: "0-23", to: "N" }, { from: "24-68", to: "NO" }, { from: "69-113", to: "O" }, { from: "114-158", to: "SO" }, { from: "159-203", to: "S" }, { from: "204-248", to: "SW" }, { from: "249-293", to: "W" }, { from: "294-338", to: "NW" }, { from: "338-360", to: "N" } ]

ottopaulsen commented 1 year ago

Please do not submit pull requests unless you are a developer and know what you are doing.

Schalmeier commented 1 year ago

In fact I am a developer, for .net though. I'm so sorry for bothering you with this poll request, I really don't no my way around on git hub. I just thought my code would be a nice addition for the project. People surely could use this function. Sorry again :(

ottopaulsen commented 1 year ago

Sorry, I did not mean to be rude, but I did expect a developer, even a .net-developer, ;-) to know the difference between Java and JavaScript. I also expect a better explanation on what the change does and why it is needed, and I expect the documentation to be updated so that users can do the configuration. Also, the code would fail if the value contains a dash (-) without being a range, and in your example above, there are many holes that would return no value at all, for example 68.5. I would prefer seach a list to only contain the from-values, so that there is less change to hit a value not configured, similar to the colors config.

So, your idea is good, but the PR is not good enough. Sorry. Feel free to improve and try again :-)