Problem with downloading the current state of the filament sensor to the macro

Hi.
I have a problem. I need to write a macro that allows me to check if the filament is loaded and perform the given actions if it is or not. The problem is that I need to use a function:
QUERY_FILAMENT_SENSOR SENSOR=fsensor
(the printer is a prusa MK3S+), because it returns the ACTUAL state of the sensor.
I am unable to write the returned value to any variable, nor am I able to retrieve the value displayed in the console in any way.
I know that I can use the function:

{% if printer[‘filament_switch_sensor fsensor’].filament_detected == False %}
{% endif %}

The problem is that with this method I don’t get the current state of the sensor in the response, but the one from before I started executing the macro. Only when the macro is executed to completion does the function return the new state of the sensor.
Is there any other way to get at this data?

2 Likes

For a better reading, please format your code as Preformatted Text

Format

3 Likes