Allow for State of 0

Fixes two things:
- Allows for a State of 0 to be recorded in the state log
- Allows for a State of 0 to be displyed through the web interface rather than N/A

Both issues arise from the use of conditional statements such as:
```
if($state){...}
```
rather than using
```
if(defined($state)){...}
```
As a result a state of 0 was always ignored.
Merge pull request #259 from krkeegan/Zero_State

Allow for State of 0