How to create a plot which shows on/off status with time?[Image Attached]

How show on/off state of something in plotly. Like in image attached state of screen,WiFi etc are shown w.r.t to time. A rectangle is shown for every ON interval.
One method is to draw rectangle for each and every interval separately using layout-shape attribute.
But in this method show/hide toggle of any one parameter say WiFi functionality by clicking on legends won’t work.

Is there any other way to do this or any graph object available for this kind of plotting?

Have you tried using a scatter trace with mode lines instead? This would solve both these issues.