Read the statement by Michael Teeuw here.
Problem with MMM-ValuesByNotification and MMM-CommandToNotification
-
Hello i used to following code to add a temperature and humitidy display to my magic mirror. i use a dht22 and i already checked the sensor with a arduino. it is working and giving reasonable outputs. But i just get “Timeout” or “0.00” as values. So did i mess up the code?
{ module: "MMM-CommandToNotification", disabled: false, config: { updateInterval: 10, commands: [ { script: "./dht22", timeout: 55, args: "12", notifications: [ "Tempout" ] } ] }, }, { module: "MMM-ValuesByNotification", position: "bottom_left", header: "Diele", config: { updateInterval: 10, reuseCount: 100, groups: [ { items: [ { notification: "Tempout", itemTitle: "Bathroom", values: [ { valueIcon: "fa fa-thermometer-full", valueUnit: "°C", valueFormat: "Number(${value}).toFixed(2)", jsonpath: "temperature", thresholds: [ { value: "15", type: "lt", classes: "lt15" }, { value: "20", type: "lt", classes: "lt20" }, ] }, { valueIcon: "fa fa-tint", valueUnit: "%rH", valueFormat: "Number(${value}).toFixed(1)", jsonpath: "humidity", }, ] }, ] }, ] }, },
-
@Jimmy1502 said in Problem with MMM-ValuesByNotification and MMM-CommandToNotification:
script: “./dht22”,
where is that file?
when MagicMirror is running the current directory is ~/MagicMirror…
NOT any module folder… -
@sdetweil Hi thx for the fast reply. This is a script from the creator of the module. In the module folder is another folder with scripts. The description how to use it is:
script: Either a absolute path or the realtive path of a script starting at the “scripts” directory. Make sure to add a “./” as prefix if you call a script in the “scripts” directory.
And in his example he did this:
{ module: "MMM-CommandToNotification", disabled: false, config: { updateInterval: 10, commands: [ { script: "./randomInteger.js", args: "-10 10", timeout: 5, notifications: [ "TEST1", "TEST2", ], }, { script: "./randomNumberJson.js", args: "-50 20", skips: 3, timeout: 10, conditions: { returnCode: [0,1,2] } notifications: [ "TEST3", ["TEST4", true] ], } ] }, },
I changed it to:
script: “./temperature/dht22”, -
@Jimmy1502 said in Problem with MMM-ValuesByNotification and MMM-CommandToNotification:
script: “./temperature/dht22”,
and did that help??
notice that I edited your posts to put code wrapper around the config.js info
please do this in the future
paste your text into the editor
blank line above and belowselect the text you just pasted,m and then hit the </> button to add the code wrapper.
the code wrapper keeps formatting and makes it easier to read
-
@sdetweil No sadly not, still getting “timeout”. I try to implement the codewrapper. Im new to this sry.
-
@Jimmy1502 said in Problem with MMM-ValuesByNotification and MMM-CommandToNotification:
I try to implement the codewrapper. Im new to this sry.
np, we all learn about it…
-
@Jimmy1502 Hi and thanks to @sdetweil for trying to help.
I will try to update the readme of the module in the next days.
The timeout is set in milliseconds. Your config looks like it is set to 5ms. The script will not be able to respond in this time.
Please increase it to a value much higher especially for the dht sensor. Let’s say something like 1000ms. -
@wishmaster270 Hi! This explains the “Timeout” and i changed it. But now i just gut “0.00” as values. Do i have other mistakes in the code? Can i use all GPIO Pins or just special ones? I tried 18,21,25.
-
@Jimmy1502
The script uses GPIO 4 in default but accepts any GPIO number as first argument.
At least GPIO 25 has no double function on raspberries and should work.You can call the script directly in the shell and check the output for debug purposes.
And make sure to check the comments in the first lines of the script if you need to. install any dependencies.Edit: Looks like you use GPIO 12 in your config which should work, too
-
@wishmaster270 this advice really helped. I tried using the script and saw, that the adafruit library was outdated. Updated it and now it kinda works. The script and my sensor is working. I get good reasonable values if i use the script manually. But the Mirror is kinda weird.
When i measured the temperature manually it said sth. around 21°C but ValuesByNotification outputs: “NaN” so Not a Number?
Humidity is kinda working. The majority of the time it is giving me a value of 47%rH but sometimes after the module is blinking (I think it is refreshing), it suddenly changes to 0.00%rH. But the next blink changes it back to a real value.Thx for your help