I am asking this after I tried to figure the answer out from the documentation but couldn't.
I am using python sensors, and as they are coded now, if something goes wrong, they print text based error messages and do not output valid JSON, which causes the sensor to display the "Structural error" message. I would like to fix that so that in case of an error, the sensor will return a valid JSON construct that will cause the banner in the sensor page to display a meaningful error message. Also, if possible, I would like the sensor to have a different status than if valid channel data was returned. For example, if I have a disk space sensor, I want the status of the sensor in case it couldn't get the disk space data, to be different than in case the data was fetched and shows that the disk is full.
Can you share the correct way to do that?