Grafana State query

I am trying to setup a State graph, which could represent how long my sonoff switch was on or off. I am using the following query, but the graph is blank. Please guide me, where I am wrong.

Select "state" FROM "state" where ("entity_id"= "switch.sonoff_100091a74f_2_state") AND $timeFilter