Best way to understand the query is the just apply is part by part to your base search and see the result (at least for small result set).
Get your result and sort in ascending order of time
Your base search | sort 0 _time
For each row, get the previous event's timestamp and DeviceValue
streamstats current=f window=1 values(DeviceValue) as prev values(_time) as prevtime
Filter first events (as that is the first status), calculate duration between current event and prev event.
| where isnotnull(prev) | eval duration=_time-prevtime
The field prev contains the previous status and duration contains how long the previous status was valid, so generate your summary using stats, use user friendly value for prev, format and display.
| stats sum(duration) as duration by prev | eval Status=if(prev=0,"Not Home","Home") | eval Duration=tostring(duration,"duration")| table Status Duration
... View more