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

Value is mostly 'Undefined' when Json data does not every time contain the parameter and value (with solution) #48

Open
thellekamp opened this issue Jul 9, 2021 · 1 comment

Comments

@thellekamp
Copy link

I am using Domoticz.
Domoticz does not send the exact same json packet each time. So most of the time (10 seconds) the value of interest is shown as 'Undefined' and the real value is only shown for an instant.
As this was not happening in an old version of MMM-MQTT, I could quickly find a solution, which does the job for me.

I made a small change in de MMM-MQTT.js code:

The location:
// Extract value if JSON Pointer is configured
if (sub.jsonpointer) {
value = get(JSON.parse(value), sub.jsonpointer);
}

//.. new test if value exists...
if (isNaN(value) == false)
{
..the rest of the .code....
}

@thellekamp
Copy link
Author

I realize the solution will not work on text values.
Better solution:

//.. new test if value exists...
if (value != null)
{
..the rest of the .code....
}

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

1 participant