Two events very close in time with wrong state

I have noticed from the Home Assistant database tabled called Events that two events got fired by Ecobee component with time difference in milliseconds has wrong status. See below 3 events; event first and third are the events I am talking about. I was expecting third event should have old_state cool not idle. Can some one explain what I am missing here?

Configuration:
  - platform: template
    sensors:
      thermostat_downstairs_current_status:
        value_template: '{{ states.thermostat.downstairs.attributes.current_operation }}'

From database events table

Event id: 12150
{
	"old_state": {
		"attributes": {
			"friendly_name": "Current Status",
			"icon": "mdi:gauge"
		},
		"last_changed": "2016-07-30T07:51:01.259577+00:00",
		"state": "idle",
		"entity_id": "sensor.thermostat_downstairs_current_status",
		"last_updated": "2016-07-30T07:51:01.259577+00:00"
	},
	"entity_id": "sensor.thermostat_downstairs_current_status",
	"new_state": {
		"attributes": {
			"friendly_name": "Current Status",
			"icon": "mdi:gauge"
		},
		"last_changed": "2016-07-30T14:35:00.637386+00:00",
		"state": "cool",
		"entity_id": "sensor.thermostat_downstairs_current_status",
		"last_updated": "2016-07-30T14:35:00.637386+00:00"
	}
}

Event id: 12151 // I just called pythin script to update some other sensor during this call and didn't modify sensor.thermostat_downstairs_current_status
{
	"service_data": {
		
	},
	"domain": "shell_command",
	"service_call_id": "140430102954784-89",
	"service": "run_ecobee_python_file"
}

Event id: 12152
{
	"old_state": {
		"attributes": {
			"friendly_name": "Current Status",
			"icon": "mdi:gauge"
		},
		"last_changed": "2016-07-30T14:35:00.826012+00:00",
		"state": "idle",
		"entity_id": "sensor.thermostat_downstairs_current_status",
		"last_updated": "2016-07-30T14:35:00.826012+00:00"
	},
	"entity_id": "sensor.thermostat_downstairs_current_status",
	"new_state": {
		"attributes": {
			"friendly_name": "Current Status",
			"icon": "mdi:gauge"
		},
		"last_changed": "2016-07-30T14:35:00.959280+00:00",
		"state": "cool",
		"entity_id": "sensor.thermostat_downstairs_current_status",
		"last_updated": "2016-07-30T14:35:00.959280+00:00"
	}
}

Thanks a lot