'Update device state.'

def update(self):

    import crimereports
    incident_counts = defaultdict(int)
    incidents = self._crimereports.get_incidents(now().date(), include=self._include, exclude=self._exclude)
    fire_events = (len(self._previous_incidents) > 0)
    if (len(incidents) < len(self._previous_incidents)):
        self._previous_incidents = set()
    for incident in incidents:
        incident_type = slugify(incident.get('type'))
        incident_counts[incident_type] += 1
        if (fire_events and (incident.get('id') not in self._previous_incidents)):
            self._incident_event(incident)
        self._previous_incidents.add(incident.get('id'))
    self._attributes = {ATTR_ATTRIBUTION: crimereports.ATTRIBUTION}
    self._attributes.update(incident_counts)
    self._state = len(incidents)
