MintyTrebor / MQTT4DSF

A Python script/service to send MQTT msgs from a SBC running Duet DSF. Uses the DSF pydsfapi plugin.
GNU General Public License v3.0
5 stars 0 forks source link

only 3 states #4

Closed lbpuma3 closed 3 years ago

lbpuma3 commented 3 years ago

hello i see only 3 states gcode status Announce

logfile 19:51:19,639 MQTT4DSF ERROR MQTT4DSF_PollingMonitor _timedMonitoring : 'NoneType' object is not subscriptable

Duet Web Control 3.2.0-beta4 Duet3 with SBC

MintyTrebor commented 3 years ago

Had Another thought. It might be that the config file is wrong for your setup (my board has a chamber heater thermistor attached) so look for the section with "MsgName" : "Temps" :

And change it to :

            "MsgName" : "Temps",
            "Type" : "STD",
            "Enabled" : "Y",
            "JSON_Variables" : [
                {   
                    "DSF_Variable_Type" : "ARRAY",
                    "DSF_DOM_Path" : "sensors/analog",
                    "Trigger_Msg" : "Y",
                    "Variables" : [                
                        {"Variable" : "lastReading", "instance" : 0, "Replace_String" : "[!*0LastRead*!]", "Var_Type" : "int", "Msg_Delta" : 2, "lastval" : "noLast"},
                        {"Variable" : "lastReading", "instance" : 1, "Replace_String" : "[!*1LastRead*!]", "Var_Type" : "int", "Msg_Delta" : 2, "lastval" : "noLast"}
                    ]

                },
                {   
                    "DSF_Variable_Type" : "ARRAY",
                    "DSF_DOM_Path" : "heat/heaters",
                    "Trigger_Msg" : "N",
                    "Variables" : [                
                        {"Variable" : "active", "instance" : 0, "Replace_String" : "[!*0HeatTarg*!]", "Var_Type" : "int", "Msg_Delta" : 0, "lastval" : "noLast"},
                        {"Variable" : "active", "instance" : 1, "Replace_String" : "[!*1HeatTarg*!]", "Var_Type" : "int", "Msg_Delta" : 0, "lastval" : "noLast"}
                    ]

                }
            ],
            "Msgs" : [
                {"MQTT_Topic_Path" : "Duet/[!*MachineName*!]/temps", "MQTT_Topic_MSG" : "Bed: [!*0LastRead*!]/[!*0HeatTarg*!] - T0 : [!*1LastRead*!]/[!*1HeatTarg*!]"}
            ]

Then see what happens.

I have updated the master config in the code to reflect this, as its more likely that users will NOT have a chamber sensor.

MintyTrebor commented 3 years ago

FYI. I have updated the code to check for invalid msg configs to give better error msgs for user. This will be in the next release. (Changes made to MQTT4DSF_Polling.py)

lbpuma3 commented 3 years ago

Thanks for Help I have update the config file and the Polling.py I see this error in logfile 11:37:17,322 MQTT4DSF WARNING Started the Log 11:37:17,323 MQTT4DSF WARNING Chnaging Log Level to = WARNING 11:37:17,329 MQTT4DSF WARNING MQTT4DSF Startup. Logging has been started 11:37:17,330 MQTT4DSF WARNING Starting GCode Proxy 11:37:17,434 MQTT4DSF ERROR MQTT4DSF_PollingMonitor: MSG Name : TempsConfiguration is invalid. Check config file for this msg's settings. Technical Err: 'sensors' 11:37:22,526 MQTT4DSF ERROR MQTT4DSF_PollingMonitor: MSG Name : TempsConfiguration is invalid. Check config file for this msg's settings. Technical Err: 'sensors'

MQTT4DSF_Config.json.txt

lbpuma3 commented 3 years ago

JSON MQTT

MintyTrebor commented 3 years ago

Can you get the latest MQTT4DSF_Polling.py and check again pls. I think the issue is because DSF is returning an empty/null array (sensor/analog/2 in your example), which I have not seen before. So I have updated the code to check for it (I hope. I have no way of testing). Your config looks valid, so whatever is happening I think it is a condition I have not experienced on my system. Sorry for inconvenience, and thanks for sticking with it.

lbpuma3 commented 3 years ago

I have updatet the MQTT4DSF_Polling.py see logfile

12:57:19,429 MQTT4DSF WARNING Started the Log 12:57:19,430 MQTT4DSF WARNING Changing Log Level to = WARNING 12:57:19,435 MQTT4DSF WARNING MQTT4DSF Startup. Logging has been started 12:57:19,436 MQTT4DSF WARNING Starting GCode Proxy 12:57:19,545 MQTT4DSF ERROR MQTT4DSF_PollingMonitor getInitialInfo : 'network'

the mqqt send not the Duet/[!MachineName!]/timesleft Duet/[!MachineName!]/temps

lbpuma3 commented 3 years ago

13:35:22,956 MQTT4DSF WARNING Started the Log 13:35:22,956 MQTT4DSF WARNING Changing Log Level to = DEBUG 13:35:22,959 MQTT4DSF WARNING MQTT4DSF Startup. Logging has been started 13:35:22,963 MQTT4DSF WARNING Starting GCode Proxy 13:35:22,998 MQTT4DSF DEBUG MQTT4DSF_SndMsg_Queue_Monitor has started 13:35:23,12 MQTT4DSF DEBUG MQTT4DSF_DSFEventMonitor _constructFilter json: [{'MsgName': 'Display Message', 'DSF_DOM_Filter': 'state/displayMessage', 'Type': 'MSG', 'Enabled': 'Y', 'JSON_Variables': [{'Variable': 'state/displayMessage', 'Replace_String': '[!DispMsg!]', 'Var_Type': 'string', 'Msg_Delta': 0, 'lastval': 'noLast'}], 'Msgs': [{'MQTT_Topic_Path': 'Duet/Announce', 'MQTT_Topic_MSG': 'Machine [!MachineName!] Msg: [!DispMsg!]'}, {'MQTT_Topic_Path': 'Duet/[!MachineName!]/displaymsg', 'MQTT_Topic_MSG': '[!DispMsg!]'}]}, {'MsgName': 'DSF Message', 'DSF_DOM_Filter': 'messages', 'Type': 'DSF', 'Enabled': 'Y', 'JSON_Variables': [{'Variable': 'messages', 'Replace_String': '[!DSFMsg!]', 'Var_Type': 'string', 'Msg_Delta': 0, 'lastval': 'noLast'}], 'Msgs': [{'MQTT_Topic_Path': 'Duet/Announce', 'MQTT_Topic_MSG': 'Machine [!MachineName!] System Msg: [!DSFMsg!]'}, {'MQTT_Topic_Path': 'Duet/[!MachineName!]/dsfmsg', 'MQTT_Topic_MSG': '[!DSFMsg!]'}]}, {'MsgName': 'Machine Status', 'DSF_DOM_Filter': 'state/status', 'Type': 'STD', 'Enabled': 'Y', 'JSON_Variables': [{'Variable': 'state/status', 'Replace_String': '[!Status!]', 'Var_Type': 'string', 'Msg_Delta': 0, 'lastval': 'noLast'}], 'Msgs': [{'MQTT_Topic_Path': 'Duet/Announce', 'MQTT_Topic_MSG': 'The Machine [!MachineName!] has changed its state to: [!Status!]'}, {'MQTT_Topic_Path': 'Duet/[!MachineName!]/status', 'MQTT_Topic_MSG': '[!Status!]'}]}, {'MsgName': 'Active Tool', 'DSF_DOM_Filter': 'state/currentTool', 'Type': 'STD', 'Enabled': 'Y', 'JSON_Variables': [{'Variable': 'state/currentTool', 'Replace_String': '[!currTool!]', 'Var_Type': 'int', 'Msg_Delta': 0, 'lastval': 'noLast'}], 'Msgs': [{'MQTT_Topic_Path': 'Duet/[!MachineName!]/currtool', 'MQTT_Topic_MSG': 'Tool [!currTool!] has been selected'}]}, {'MsgName': 'Job Name', 'DSF_DOM_Filter': 'job/file/fileName', 'Type': 'STD', 'Enabled': 'Y', 'JSON_Variables': [{'Variable': 'job/file/fileName', 'Replace_String': '[!jobName!]', 'Var_Type': 'string', 'Msg_Delta': 0, 'lastval': 'noLast'}], 'Msgs': [{'MQTT_Topic_Path': 'Duet/[!MachineName!]/jobname', 'MQTT_Topic_MSG': 'Started job: [!jobName!]'}, {'MQTT_Topic_Path': 'Duet/Announce', 'MQTT_Topic_MSG': 'Machine [!MachineName!] has started job: [!jobName!]'}]}, {'MsgName': 'Current Layer', 'DSF_DOM_Filter': 'job/layer', 'Type': 'STD', 'Enabled': 'Y', 'JSON_Variables': [{'Variable': 'job/layer', 'Replace_String': '[!layer!]', 'Var_Type': 'int', 'Msg_Delta': 0, 'lastval': 'noLast'}], 'Msgs': [{'MQTT_Topic_Path': 'Duet/[!MachineName!]/joblayer', 'MQTT_Topic_MSG': '[!layer!]'}]}] 13:35:23,14 MQTT4DSF DEBUG MQTT4DSF_DSFEventMonitor _constructFilter DSF API Filter : messages|job/layer|state/displayMessage|state/currentTool|state/status|job/file/fileName 13:35:23,24 MQTT4DSF DEBUG GCodeProxy _GCodeProxy_On_MQTT_Connect - Subscribed To: Duet/MK2sRRF/gcode 13:35:23,26 MQTT4DSF DEBUG GCodeProxy _GCodeProxy_On_MQTT_MSG - Sending: 13:35:23,30 MQTT4DSF DEBUG MQTT4DSF Is getting the Startup MSG 13:35:23,137 MQTT4DSF ERROR MQTT4DSF_PollingMonitor getInitialInfo : 'network'

lbpuma3 commented 3 years ago

13:35:23,14 MQTT4DSF DEBUG MQTT4DSF_DSFEventMonitor _constructFilter DSF API Filter : messages|job/layer|state/displayMessage|state/currentTool|state/status|job/file/fileName

in this line is not temps or timesleft?

MintyTrebor commented 3 years ago

No. Those are for pushed events from DSF through a python api. Temps, Times Left etc are pulled through HTTP rest api because they update too frequently and would overload the DSF python api.

I'm still looking into what is causing the MQTT4DSF_PollingMonitor getInitialInfo : 'network' error can you send me the full json txt from http://[[IP_ADD]]/machine/status and your config file again please

lbpuma3 commented 3 years ago

Hello Thanks thats you help me.

status.json.txt MQTT4DSF_Config.json.txt

MintyTrebor commented 3 years ago

It would appear that Duet have changed the format of the json returned from http://[IP]/machine/status for either the latest versions, or just for your board type!!!. Can you try using the attached updated config, and python files please, and let me know the results. I'm not expecting it to fix everything but hopefully it will confirm my theory. MQTT4DSF_Config.json.txt MQTT4DSF_Polling.py.txt

For Clarification: Assuming you are using latest version, it would appear that Duet have re-instated an older json format. The format my plugin is expecting is for example : job/timesLeft However the older format would be: result/job/timesLeft

Your http://[IP]/machine/status json is using the result/job/timesLeft format.

lbpuma3 commented 3 years ago

Perfekt it`s work Big Thanks

MintyTrebor commented 3 years ago

Great. Thanks for helping me diagnose the issue. I will update the code to try and find a way of automatically dealing with the 2 different json formats in a more user friendly way.

lbpuma3 commented 3 years ago

Last question, is it possible that the temps are not shared in one mqtt temps: Bed: 75/75 - T0 : 210.2/210?

tempT0ist: 210,2 tempT0soll: 210 tempbedist: 75 tempbetsol: 75

MintyTrebor commented 3 years ago

Yes. That can be done through the config file. I had a go at it for you (attached). Backup your current config file before replacing.

If it works it should publish to topics:

CurrBedTemp
TargBedTemp
CurrT0Temp
TargT0Temp

MQTT4DSF_Config.json.txt

lbpuma3 commented 3 years ago

Thanks its work perfekt 👍